diff options
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() |