-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |||
"path" | ||||
"runtime" | ||||
"sort" | ||||
"sync" | ||||
"testing" | ||||
|
||||
"github.com/Masterminds/semver" | ||||
|
@@ -338,3 +339,141 @@ func TestGetInfoListVersionsOrdering(t *testing.T) { | |||
t.Errorf("Expected three results from ListVersions, got %v", len(v)) | ||||
} | ||||
} | ||||
|
||||
func TestDeduceProjectRoot(t *testing.T) { | ||||
sm, clean := mkNaiveSM(t) | ||||
defer clean() | ||||
|
||||
in := "github.com/sdboyer/gps" | ||||
pr, err := sm.DeduceProjectRoot(in) | ||||
if err != nil { | ||||
t.Errorf("Problem while detecting root of %q %s", in, err) | ||||
} | ||||
if string(pr) != in { | ||||
t.Errorf("Wrong project root was deduced;\n\t(GOT) %s\n\t(WNT) %s", pr, in) | ||||
} | ||||
if sm.rootxt.Len() != 1 { | ||||
t.Errorf("Root path trie should have one element after one deduction, has %v", sm.rootxt.Len()) | ||||
} | ||||
|
||||
pr, err = sm.DeduceProjectRoot(in) | ||||
if err != nil { | ||||
t.Errorf("Problem while detecting root of %q %s", in, err) | ||||
} else if string(pr) != in { | ||||
t.Errorf("Wrong project root was deduced;\n\t(GOT) %s\n\t(WNT) %s", pr, in) | ||||
} | ||||
if sm.rootxt.Len() != 1 { | ||||
t.Errorf("Root path trie should have one element after performing the same deduction twice; has %v", sm.rootxt.Len()) | ||||
} | ||||
|
||||
// Now do a subpath | ||||
sub := path.Join(in, "foo") | ||||
pr, err = sm.DeduceProjectRoot(sub) | ||||
if err != nil { | ||||
t.Errorf("Problem while detecting root of %q %s", sub, err) | ||||
} else if string(pr) != in { | ||||
t.Errorf("Wrong project root was deduced;\n\t(GOT) %s\n\t(WNT) %s", pr, in) | ||||
} | ||||
if sm.rootxt.Len() != 2 { | ||||
t.Errorf("Root path trie should have two elements, one for root and one for subpath; has %v", sm.rootxt.Len()) | ||||
} | ||||
|
||||
// Now do a fully different root, but still on github | ||||
in2 := "github.com/bagel/lox" | ||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sdboyer
Author
Owner
|
c.Env = mergeEnvLists([]string{"GIT_TERMINAL_PROMPT=0"}, os.Environ()) |
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
Using nonexistent github repo makes
go test
prompts for github username and password to check if you have rights for a closed repo. Little confusing when you run it for the first time.