Factor RemoteSplit into fs
This commit is contained in:
parent
74a3dfc4e1
commit
d30cc1e119
3 changed files with 32 additions and 27 deletions
35
fs/path_test.go
Normal file
35
fs/path_test.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package fs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRemoteSplit(t *testing.T) {
|
||||
|
||||
for _, test := range []struct {
|
||||
remote, wantParent, wantLeaf string
|
||||
}{
|
||||
{"", "", ""},
|
||||
{"remote:", "remote:", ""},
|
||||
{"remote:potato", "remote:", "potato"},
|
||||
{"remote:/", "remote:/", ""},
|
||||
{"remote:/potato", "remote:/", "potato"},
|
||||
{"remote:/potato/potato", "remote:/potato/", "potato"},
|
||||
{"remote:potato/sausage", "remote:potato/", "sausage"},
|
||||
{"/", "/", ""},
|
||||
{"/root", "/", "root"},
|
||||
{"/a/b", "/a/", "b"},
|
||||
{"root", "", "root"},
|
||||
{"a/b", "a/", "b"},
|
||||
{"root/", "root/", ""},
|
||||
{"a/b/", "a/b/", ""},
|
||||
} {
|
||||
gotParent, gotLeaf := RemoteSplit(test.remote)
|
||||
assert.Equal(t, test.wantParent, gotParent, test.remote)
|
||||
assert.Equal(t, test.wantLeaf, gotLeaf, test.remote)
|
||||
assert.Equal(t, test.remote, gotParent+gotLeaf, fmt.Sprintf("%s: %q + %q != %q", test.remote, gotParent, gotLeaf, test.remote))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue