forked from golang/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/modindex: better behavior in edge cases
Write an index even if there is nothing in the module cache. Change-Id: Ia98f8825d9914a0d4bd2ee9ff1bccf8519b91f37 Reviewed-on: https://go-review.googlesource.com/c/tools/+/626735 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
- Loading branch information
Showing
3 changed files
with
47 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,41 +205,42 @@ func TestDirsSinglePath(t *testing.T) { | |
} | ||
} | ||
|
||
/* more data for tests | ||
directories.go:169: WEIRD cloud.google.com/go/iam/admin/apiv1 | ||
map[cloud.google.com/go:1 cloud.google.com/go/iam:5]: | ||
[cloud.google.com/go/[email protected]/admin/apiv1 | ||
cloud.google.com/go/[email protected]/admin/apiv1 | ||
cloud.google.com/go/[email protected]/admin/apiv1 | ||
cloud.google.com/go/[email protected]/admin/apiv1 | ||
cloud.google.com/go/[email protected]/admin/apiv1 | ||
cloud.google.com/[email protected]/iam/admin/apiv1] | ||
directories.go:169: WEIRD cloud.google.com/go/iam | ||
map[cloud.google.com/go:1 cloud.google.com/go/iam:5]: | ||
[cloud.google.com/go/[email protected] cloud.google.com/go/[email protected] | ||
cloud.google.com/go/[email protected] cloud.google.com/go/[email protected] | ||
cloud.google.com/go/[email protected] cloud.google.com/[email protected]/iam] | ||
directories.go:169: WEIRD cloud.google.com/go/compute/apiv1 | ||
map[cloud.google.com/go:1 cloud.google.com/go/compute:4]: | ||
[cloud.google.com/go/[email protected]/apiv1 | ||
cloud.google.com/go/[email protected]/apiv1 | ||
cloud.google.com/go/[email protected]/apiv1 | ||
cloud.google.com/go/[email protected]/apiv1 | ||
cloud.google.com/[email protected]/compute/apiv1] | ||
directories.go:169: WEIRD cloud.google.com/go/longrunning/autogen | ||
map[cloud.google.com/go:2 cloud.google.com/go/longrunning:2]: | ||
[cloud.google.com/go/[email protected]/autogen | ||
cloud.google.com/go/[email protected]/autogen | ||
cloud.google.com/[email protected]/longrunning/autogen | ||
cloud.google.com/[email protected]/longrunning/autogen] | ||
directories.go:169: WEIRD cloud.google.com/go/iam/credentials/apiv1 | ||
map[cloud.google.com/go:1 cloud.google.com/go/iam:5]: | ||
[cloud.google.com/go/[email protected]/credentials/apiv1 | ||
cloud.google.com/go/[email protected]/credentials/apiv1 | ||
cloud.google.com/go/[email protected]/credentials/apiv1 | ||
cloud.google.com/go/[email protected]/credentials/apiv1 | ||
cloud.google.com/go/[email protected]/credentials/apiv1 | ||
cloud.google.com/[email protected]/iam/credentials/apiv1] | ||
func TestMissingCachedir(t *testing.T) { | ||
// behave properly if the cached dir is empty | ||
dir := testModCache(t) | ||
if err := Create(dir); err != nil { | ||
t.Fatal(err) | ||
} | ||
ixd, err := IndexDir() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
des, err := os.ReadDir(ixd) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if len(des) != 2 { | ||
t.Errorf("got %d, butexpected two entries in index dir", len(des)) | ||
} | ||
} | ||
|
||
*/ | ||
func TestMissingIndex(t *testing.T) { | ||
// behave properly if there is no existing index | ||
dir := testModCache(t) | ||
if ok, err := Update(dir); err != nil { | ||
t.Fatal(err) | ||
} else if !ok { | ||
t.Error("Update returned !ok") | ||
} | ||
ixd, err := IndexDir() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
des, err := os.ReadDir(ixd) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if len(des) != 2 { | ||
t.Errorf("got %d, butexpected two entries in index dir", len(des)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters