diff options
author | Joe Chen <jc@unknwon.io> | 2022-10-23 21:53:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-23 21:53:11 +0800 |
commit | f6acc4763ed0158473e0046ac9fb86597d5a516e (patch) | |
tree | df61952e59a9c00dd8a678b6bdbd000903bc7313 /internal/db/two_factors_test.go | |
parent | 3265abfbc22ef36871d8e69f0f9a3a4a5b40b768 (diff) |
test(db): add missing tests (#7208)
Diffstat (limited to 'internal/db/two_factors_test.go')
-rw-r--r-- | internal/db/two_factors_test.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/internal/db/two_factors_test.go b/internal/db/two_factors_test.go index 36e4eeca..ddff3fce 100644 --- a/internal/db/two_factors_test.go +++ b/internal/db/two_factors_test.go @@ -29,7 +29,9 @@ func TestTwoFactor_BeforeCreate(t *testing.T) { } t.Run("CreatedUnix has been set", func(t *testing.T) { - tf := &TwoFactor{CreatedUnix: 1} + tf := &TwoFactor{ + CreatedUnix: 1, + } _ = tf.BeforeCreate(db) assert.Equal(t, int64(1), tf.CreatedUnix) }) @@ -41,6 +43,24 @@ func TestTwoFactor_BeforeCreate(t *testing.T) { }) } +func TestTwoFactor_AfterFind(t *testing.T) { + now := time.Now() + db := &gorm.DB{ + Config: &gorm.Config{ + SkipDefaultTransaction: true, + NowFunc: func() time.Time { + return now + }, + }, + } + + tf := &TwoFactor{ + CreatedUnix: now.Unix(), + } + _ = tf.AfterFind(db) + assert.Equal(t, tf.CreatedUnix, tf.Created.Unix()) +} + func TestTwoFactors(t *testing.T) { if testing.Short() { t.Skip() |