add more tests

This commit is contained in:
Lee Briggs 2020-08-31 19:01:23 -07:00
parent ed94132080
commit f5a54cf6bb
No known key found for this signature in database
GPG key ID: A4D09B96FDFEB505
2 changed files with 6 additions and 1 deletions

View file

@ -1845,7 +1845,7 @@ func getRewritePath(pkg string, gopath string, depRoot string) string {
// Get the package name
// This is the value after "github.com/foo/bar"
repoName := splitPkg[2]
basePath := filepath.Base(sanitizedPkg)
basePath := splitPkg[len(splitPkg)-1]
if basePath == repoName {
depParts = append([]string{depRoot, repoName})
} else {

View file

@ -93,4 +93,9 @@ func TestDepRootCalc(t *testing.T) {
dep = getRewritePath("github.com/example/foo/v2", "/gopath", "/my-go-src")
assert.Equal(t, "/my-go-src/foo", dep)
dep = getRewritePath("github.com/example/foo", "/gopath", "/my-go-src")
assert.Equal(t, "/my-go-src/foo", dep)
dep = getRewritePath("github.com/pulumi/pulumi-auth0/sdk", "gopath", "/my-go-src")
assert.Equal(t, "/my-go-src/pulumi-auth0/sdk", dep)
}