mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-27 11:27:56 +08:00
32 lines
663 B
Go
32 lines
663 B
Go
|
package weed_server
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestParseURL(t *testing.T) {
|
||
|
if vid, fid, _, _, _ := parseURLPath("/1,06dfa8a684"); true {
|
||
|
if vid != "1" {
|
||
|
t.Errorf("fail to parse vid: %s", vid)
|
||
|
}
|
||
|
if fid != "06dfa8a684" {
|
||
|
t.Errorf("fail to parse fid: %s", fid)
|
||
|
}
|
||
|
}
|
||
|
if vid, fid, _, _, _ := parseURLPath("/1,06dfa8a684_1"); true {
|
||
|
if vid != "1" {
|
||
|
t.Errorf("fail to parse vid: %s", vid)
|
||
|
}
|
||
|
if fid != "06dfa8a684_1" {
|
||
|
t.Errorf("fail to parse fid: %s", fid)
|
||
|
}
|
||
|
if sepIndex := strings.LastIndex(fid, "_"); sepIndex > 0 {
|
||
|
fid = fid[:sepIndex]
|
||
|
}
|
||
|
if fid != "06dfa8a684" {
|
||
|
t.Errorf("fail to parse fid: %s", fid)
|
||
|
}
|
||
|
}
|
||
|
}
|