fspath: add unit tests for remote names with space

This commit is contained in:
albertony 2022-09-16 16:11:54 +02:00 committed by Nick Craig-Wood
parent 53ff5bb205
commit 4120dffcc1

View File

@ -37,6 +37,10 @@ func TestCheckConfigName(t *testing.T) {
{".", nil}, {".", nil},
{"..", nil}, {"..", nil},
{".r.e.m.o.t.e.", nil}, {".r.e.m.o.t.e.", nil},
{"rem ote", nil},
{"remote ", nil},
{" remote", nil},
{" remote ", nil},
} { } {
got := CheckConfigName(test.in) got := CheckConfigName(test.in)
assert.Equal(t, test.want, got, test.in) assert.Equal(t, test.want, got, test.in)
@ -54,6 +58,10 @@ func TestCheckRemoteName(t *testing.T) {
{".:", nil}, {".:", nil},
{"..:", nil}, {"..:", nil},
{".r.e.m.o.t.e.:", nil}, {".r.e.m.o.t.e.:", nil},
{"rem ote:", nil},
{"remote :", nil},
{" remote:", nil},
{" remote :", nil},
{"", errInvalidCharacters}, {"", errInvalidCharacters},
{"rem:ote", errInvalidCharacters}, {"rem:ote", errInvalidCharacters},
{"rem:ote:", errInvalidCharacters}, {"rem:ote:", errInvalidCharacters},
@ -209,6 +217,34 @@ func TestParse(t *testing.T) {
Name: "rem.ote", Name: "rem.ote",
Path: "/path/to/file", Path: "/path/to/file",
}, },
}, {
in: "rem ote:/path/to/file",
wantParsed: Parsed{
ConfigString: "rem ote",
Name: "rem ote",
Path: "/path/to/file",
},
}, {
in: "remote :/path/to/file",
wantParsed: Parsed{
ConfigString: "remote ",
Name: "remote ",
Path: "/path/to/file",
},
}, {
in: " remote:/path/to/file",
wantParsed: Parsed{
ConfigString: " remote",
Name: " remote",
Path: "/path/to/file",
},
}, {
in: " remote :/path/to/file",
wantParsed: Parsed{
ConfigString: " remote ",
Name: " remote ",
Path: "/path/to/file",
},
}, { }, {
in: "rem#ote:/path/to/file", in: "rem#ote:/path/to/file",
wantErr: errInvalidCharacters, wantErr: errInvalidCharacters,
@ -444,6 +480,11 @@ func TestSplitFs(t *testing.T) {
{"remote:potato/sausage", "remote:", "potato/sausage", nil}, {"remote:potato/sausage", "remote:", "potato/sausage", nil},
{"rem.ote:potato/sausage", "rem.ote:", "potato/sausage", nil}, {"rem.ote:potato/sausage", "rem.ote:", "potato/sausage", nil},
{"rem ote:", "rem ote:", "", nil},
{"remote :", "remote :", "", nil},
{" remote:", " remote:", "", nil},
{" remote :", " remote :", "", nil},
{".:", ".:", "", nil}, {".:", ".:", "", nil},
{"..:", "..:", "", nil}, {"..:", "..:", "", nil},
{".:potato/sausage", ".:", "potato/sausage", nil}, {".:potato/sausage", ".:", "potato/sausage", nil},
@ -496,6 +537,11 @@ func TestSplit(t *testing.T) {
{"remote:potato/sausage", "remote:potato/", "sausage", nil}, {"remote:potato/sausage", "remote:potato/", "sausage", nil},
{"rem.ote:potato/sausage", "rem.ote:potato/", "sausage", nil}, {"rem.ote:potato/sausage", "rem.ote:potato/", "sausage", nil},
{"rem ote:", "rem ote:", "", nil},
{"remote :", "remote :", "", nil},
{" remote:", " remote:", "", nil},
{" remote :", " remote :", "", nil},
{".:", ".:", "", nil}, {".:", ".:", "", nil},
{"..:", "..:", "", nil}, {"..:", "..:", "", nil},
{".:potato/sausage", ".:potato/", "sausage", nil}, {".:potato/sausage", ".:potato/", "sausage", nil},