From a69ac566aab41c4b7629eaa3f5f7d560894bf738 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Tue, 8 Jul 2025 15:14:05 +0000 Subject: [PATCH] first commit: hugodutka/dbmem-site --- site/site_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/site/site_test.go b/site/site_test.go index f7301debba2be..fa3c0809f22a7 100644 --- a/site/site_test.go +++ b/site/site_test.go @@ -27,7 +27,6 @@ import ( "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/db2sdk" "github.com/coder/coder/v2/coderd/database/dbgen" - "github.com/coder/coder/v2/coderd/database/dbmem" "github.com/coder/coder/v2/coderd/database/dbtestutil" "github.com/coder/coder/v2/coderd/database/dbtime" "github.com/coder/coder/v2/coderd/httpmw" @@ -46,7 +45,7 @@ func TestInjection(t *testing.T) { }, } binFs := http.FS(fstest.MapFS{}) - db := dbmem.New() + db, _ := dbtestutil.NewDB(t) handler := site.New(&site.Options{ Telemetry: telemetry.NewNoop(), BinFS: binFs, @@ -73,13 +72,17 @@ func TestInjection(t *testing.T) { // This will update as part of the request! got.LastSeenAt = user.LastSeenAt + // json.Unmarshal doesn't parse the timezone correctly + got.CreatedAt = got.CreatedAt.In(user.CreatedAt.Location()) + got.UpdatedAt = got.UpdatedAt.In(user.CreatedAt.Location()) + require.Equal(t, db2sdk.User(user, []uuid.UUID{}), got) } func TestInjectionFailureProducesCleanHTML(t *testing.T) { t.Parallel() - db := dbmem.New() + db, _ := dbtestutil.NewDB(t) // Create an expired user with a refresh token, but provide no OAuth2 // configuration so that refresh is impossible, this should result in