Fix parsing of remotes in moveto and copyto - fixes #1079

This commit is contained in:
Nick Craig-Wood
2017-02-22 21:24:04 +00:00
parent 07dc76eff0
commit 30e97ad9ec
2 changed files with 26 additions and 22 deletions

View File

@ -1,6 +1,7 @@
package cmd
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
@ -12,17 +13,23 @@ func TestRemoteSplit(t *testing.T) {
remote, wantParent, wantLeaf string
}{
{"", "", ""},
{"remote:", "", ""},
{"remote:", "remote:", ""},
{"remote:potato", "remote:", "potato"},
{"remote:potato/sausage", "remote:potato", "sausage"},
{"/", "", ""},
{"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"},
{"/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))
}
}