aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/insert_module_test.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2020-04-27 07:52:23 -0400
committerJonathan Amsterdam <jba@google.com>2020-04-30 20:44:58 +0000
commitfbe5e95f5fb8840efba59f2d344bd25b0f55854b (patch)
treec2e0f2597ff3482723351805f6d99b80dfbf6935 /internal/postgres/insert_module_test.go
parent4837cb2a2c968d9af1aea5c5bd63eb0a9ef3d50a (diff)
downloadgo-x-pkgsite-fbe5e95f5fb8840efba59f2d344bd25b0f55854b.tar.xz
internal/postgres: delete module from imports_unique
When we delete the last version of a module, remove it from imports_unique. Updates b/154616892. Change-Id: I988c439ae117cca4b79ea33752f730fb48c2496f Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/728094 Reviewed-by: Julie Qiu <julieqiu@google.com>
Diffstat (limited to 'internal/postgres/insert_module_test.go')
-rw-r--r--internal/postgres/insert_module_test.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index 75f4a985..67554906 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -6,6 +6,7 @@ package postgres
import (
"context"
+ "database/sql"
"errors"
"io/ioutil"
"path/filepath"
@@ -259,7 +260,7 @@ func TestPostgres_ReadAndWriteModuleOtherColumns(t *testing.T) {
}
}
-func TestPostgres_DeleteVersion(t *testing.T) {
+func TestPostgres_DeleteModule(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
defer ResetTestDB(testDB, t)
@@ -277,6 +278,13 @@ func TestPostgres_DeleteVersion(t *testing.T) {
if _, err := testDB.GetModuleInfo(ctx, v.ModulePath, v.Version); !errors.Is(err, derrors.NotFound) {
t.Errorf("got %v, want NotFound", err)
}
+ var x int
+ err := testDB.Underlying().QueryRow(ctx, "SELECT 1 FROM imports_unique WHERE from_module_path = $1",
+ v.ModulePath).Scan(&x)
+ if err != sql.ErrNoRows {
+ t.Errorf("imports_unique: got %v, want ErrNoRows", err)
+ }
+ // TODO(b/154616892): check removal from version_map
}
func TestPostgres_NewerAlternative(t *testing.T) {