internal/frontend: fix latest-version test
Change-Id: Ie0c90a3626c2f418dc5aa46b0579282849e4fe3f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/280616
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/internal/frontend/latest_version_test.go b/internal/frontend/latest_version_test.go
index 12c866c..cdbce8f 100644
--- a/internal/frontend/latest_version_test.go
+++ b/internal/frontend/latest_version_test.go
@@ -39,33 +39,32 @@
wantErr error
}{
{
- name: "get latest minor version for a persisted module",
- fullPath: "github.com/mymodule/av1module",
- modulePath: internal.UnknownModulePath,
+ name: "package",
+ fullPath: "github.com/mymodule/av1module/bar",
+ modulePath: "github.com/mymodule/av1module",
wantMinorVersion: "v1.0.1",
- wantErr: nil,
},
{
- name: "module does not exist",
- fullPath: "github.com/mymodule/doesnotexist",
- modulePath: internal.UnknownModulePath,
- wantMinorVersion: "",
- wantErr: fmt.Errorf("error while retriving minor version"),
+ name: "module",
+ fullPath: "github.com/mymodule/av1module",
+ modulePath: "github.com/mymodule/av1module",
+ wantMinorVersion: "v1.0.1",
+ },
+ {
+ name: "module does not exist",
+ fullPath: "github.com/mymodule/doesnotexist",
+ modulePath: internal.UnknownModulePath,
+ wantErr: fmt.Errorf("error while retriving minor version"),
},
}
ctx := context.Background()
insertTestModules(ctx, t, persistedModules)
+ svr := &Server{getDataSource: func(context.Context) internal.DataSource { return testDB }}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
- v, err := latestMinorVersion(ctx, testDB, tc.fullPath, tc.modulePath)
- if err != nil {
- if tc.wantErr == nil {
- t.Fatalf("got %v, want no error", err)
- }
- return
- }
- if v != tc.wantMinorVersion {
- t.Fatalf("got %q, want %q", tc.wantMinorVersion, v)
+ got := svr.GetLatestInfo(ctx, tc.fullPath, tc.modulePath)
+ if got.MinorVersion != tc.wantMinorVersion {
+ t.Fatalf("got %q, want %q", tc.wantMinorVersion, got.MinorVersion)
}
})
}