From d67e59658d75b85a6481a1394ad77c8e16fd20f6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 30 Jan 2023 11:20:27 +0100 Subject: [PATCH] Use database.User.SetPassword in server tests --- server_test.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server_test.go b/server_test.go index f2d17d0..74a2e1f 100644 --- a/server_test.go +++ b/server_test.go @@ -6,7 +6,6 @@ import ( "os" "testing" - "golang.org/x/crypto/bcrypt" "gopkg.in/irc.v4" "git.sr.ht/~emersion/soju/database" @@ -46,16 +45,13 @@ func createTempPostgresDB(t *testing.T) database.Database { } func createTestUser(t *testing.T, db database.Database) *database.User { - hashed, err := bcrypt.GenerateFromPassword([]byte(testPassword), bcrypt.DefaultCost) - if err != nil { - t.Fatalf("failed to generate bcrypt hash: %v", err) - } - record := &database.User{ Username: testUsername, - Password: string(hashed), Enabled: true, } + if err := record.SetPassword(testPassword); err != nil { + t.Fatalf("failed to generate bcrypt hash: %v", err) + } if err := db.StoreUser(context.Background(), record); err != nil { t.Fatalf("failed to store test user: %v", err) }