Prevent addition of duplicate path prefixes.
I think I understand this now; the failure comes from here: https://golang.org/src/cmd/go/vcs.go#L818 and makes it so one can't both host: - github.com/foo - github.com/foo/bar which would have to clone the latter inside of the former. Fixes #1.
This commit is contained in:
@@ -35,3 +35,60 @@ func TestVcsStrings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValid(t *testing.T) {
|
||||
tests := []struct {
|
||||
pkgs []Package
|
||||
in string
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
pkgs: []Package{},
|
||||
in: "bobo",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
pkgs: []Package{
|
||||
{Path: ""},
|
||||
},
|
||||
in: "bobo",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
pkgs: []Package{
|
||||
{Path: "bobo"},
|
||||
},
|
||||
in: "bobo",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
pkgs: []Package{
|
||||
{Path: "a/b/c"},
|
||||
},
|
||||
in: "a/b/c",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
pkgs: []Package{
|
||||
{Path: "foo/bar"},
|
||||
{Path: "foo/baz"},
|
||||
},
|
||||
in: "foo",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
pkgs: []Package{
|
||||
{Path: "bilbo"},
|
||||
{Path: "frodo"},
|
||||
},
|
||||
in: "foo/bar/baz",
|
||||
want: true,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
got := Valid(test.in, test.pkgs)
|
||||
if got != test.want {
|
||||
t.Errorf("Incorrect testing of %q against %#v; got %t, want %t", test.in, test.pkgs, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user