internal/postgres: move TestGetStdlib to stdlib_test.go
Change-Id: I59b91e8785dfb0d0657b6285175c447b0ccdd119
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/277652
Run-TryBot: Julie Qiu <julie@golang.org>
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/postgres/path_test.go b/internal/postgres/path_test.go
index 8d4e121..9d80fe2 100644
--- a/internal/postgres/path_test.go
+++ b/internal/postgres/path_test.go
@@ -15,7 +15,6 @@
"golang.org/x/pkgsite/internal"
"golang.org/x/pkgsite/internal/licenses"
"golang.org/x/pkgsite/internal/source"
- "golang.org/x/pkgsite/internal/stdlib"
"golang.org/x/pkgsite/internal/testing/sample"
)
@@ -391,49 +390,3 @@
}
}
}
-
-func TestGetStdlibPaths(t *testing.T) {
- ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
- defer cancel()
- defer ResetTestDB(testDB, t)
-
- // Insert two versions of some stdlib packages.
- for _, data := range []struct {
- version string
- suffixes []string
- }{
- {
- // earlier version; should be ignored
- "v1.1.0",
- []string{"bad/json"},
- },
- {
- "v1.2.0",
- []string{
- "encoding/json",
- "archive/json",
- "net/http", // no "json"
- "foo/json/moo", // "json" not the last component
- "bar/xjson", // "json" not alone
- "baz/jsonx", // ditto
- },
- },
- } {
- m := sample.Module(stdlib.ModulePath, data.version, data.suffixes...)
- for _, p := range m.Packages() {
- p.Imports = nil
- }
- if err := testDB.InsertModule(ctx, m); err != nil {
- t.Fatal(err)
- }
- }
-
- got, err := testDB.GetStdlibPathsWithSuffix(ctx, "json")
- if err != nil {
- t.Fatal(err)
- }
- want := []string{"archive/json", "encoding/json"}
- if !cmp.Equal(got, want) {
- t.Errorf("got %v, want %v", got, want)
- }
-}
diff --git a/internal/postgres/stdlib_test.go b/internal/postgres/stdlib_test.go
new file mode 100644
index 0000000..19e473b
--- /dev/null
+++ b/internal/postgres/stdlib_test.go
@@ -0,0 +1,60 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package postgres
+
+import (
+ "context"
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "golang.org/x/pkgsite/internal/stdlib"
+ "golang.org/x/pkgsite/internal/testing/sample"
+)
+
+func TestGetStdlibPaths(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+ defer cancel()
+ defer ResetTestDB(testDB, t)
+
+ // Insert two versions of some stdlib packages.
+ for _, data := range []struct {
+ version string
+ suffixes []string
+ }{
+ {
+ // earlier version; should be ignored
+ "v1.1.0",
+ []string{"bad/json"},
+ },
+ {
+ "v1.2.0",
+ []string{
+ "encoding/json",
+ "archive/json",
+ "net/http", // no "json"
+ "foo/json/moo", // "json" not the last component
+ "bar/xjson", // "json" not alone
+ "baz/jsonx", // ditto
+ },
+ },
+ } {
+ m := sample.Module(stdlib.ModulePath, data.version, data.suffixes...)
+ for _, p := range m.Packages() {
+ p.Imports = nil
+ }
+ if err := testDB.InsertModule(ctx, m); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ got, err := testDB.GetStdlibPathsWithSuffix(ctx, "json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ want := []string{"archive/json", "encoding/json"}
+ if !cmp.Equal(got, want) {
+ t.Errorf("got %v, want %v", got, want)
+ }
+}