aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/postgres_test.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2021-09-10 10:20:18 -0400
committerJonathan Amsterdam <jba@google.com>2021-09-10 15:18:15 +0000
commitfe8b5ffc8f193bc30fc3384bf210413f33524484 (patch)
treed98c0eb0b52898e7194c85a40d5bd80f6f6a4a7c /internal/postgres/postgres_test.go
parent6320d9fa2cc187dbcabf8b50478b0e1ec99302fe (diff)
downloadgo-x-pkgsite-fe8b5ffc8f193bc30fc3384bf210413f33524484.tar.xz
internal/postgres: get DB user info
Add a method for getting information about a DB user. We plan to use this on the worker to see if we can make better load-shedding decisions. For golang/go#48010 Change-Id: I80f2811f657ac47d94446a47a38e00502ae29ae8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/348933 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/postgres/postgres_test.go')
-rw-r--r--internal/postgres/postgres_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/postgres/postgres_test.go b/internal/postgres/postgres_test.go
index 4240ed13..5550b7d8 100644
--- a/internal/postgres/postgres_test.go
+++ b/internal/postgres/postgres_test.go
@@ -111,3 +111,20 @@ func TestGetOldestUnprocessedIndexTime(t *testing.T) {
})
}
}
+
+func TestGetUserInfo(t *testing.T) {
+ // We can't know what we'll get from this query, so just perform some basic
+ // sanity checks.
+ t.Parallel()
+ ctx := context.Background()
+ testDB, release := acquire(t)
+ defer release()
+
+ got, err := testDB.GetUserInfo(ctx, "postgres")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got.NumTotal < 1 {
+ t.Errorf("total = %d, wanted >= 1", got.NumTotal)
+ }
+}