aboutsummaryrefslogtreecommitdiff
path: root/internal/db/actions_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/actions_test.go')
-rw-r--r--internal/db/actions_test.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/internal/db/actions_test.go b/internal/db/actions_test.go
index ea50b9b4..9c8dae37 100644
--- a/internal/db/actions_test.go
+++ b/internal/db/actions_test.go
@@ -61,7 +61,9 @@ func TestAction_BeforeCreate(t *testing.T) {
}
t.Run("CreatedUnix has been set", func(t *testing.T) {
- action := &Action{CreatedUnix: 1}
+ action := &Action{
+ CreatedUnix: 1,
+ }
_ = action.BeforeCreate(db)
assert.Equal(t, int64(1), action.CreatedUnix)
})
@@ -73,6 +75,24 @@ func TestAction_BeforeCreate(t *testing.T) {
})
}
+func TestAction_AfterFind(t *testing.T) {
+ now := time.Now()
+ db := &gorm.DB{
+ Config: &gorm.Config{
+ SkipDefaultTransaction: true,
+ NowFunc: func() time.Time {
+ return now
+ },
+ },
+ }
+
+ action := &Action{
+ CreatedUnix: now.Unix(),
+ }
+ _ = action.AfterFind(db)
+ assert.Equal(t, action.CreatedUnix, action.Created.Unix())
+}
+
func TestActions(t *testing.T) {
if testing.Short() {
t.Skip()