1
0

chore(task): add test to check if a task's reminders are duplicated

This commit is contained in:
kolaente
2023-01-26 16:06:49 +01:00
parent f2b4e9260b
commit 40411e4100
2 changed files with 30 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package models
import (
"testing"
"time"
"xorm.io/builder"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/events"
@ -367,6 +368,27 @@ func TestTask_Update(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, int64(3), task.Index)
})
t.Run("the same date multiple times should be saved once", func(t *testing.T) {
db.LoadAndAssertFixtures(t)
s := db.NewSession()
defer s.Close()
task := &Task{
ID: 1,
Title: "test",
Reminders: []time.Time{
time.Unix(1674745156, 0),
time.Unix(1674745156, 223),
},
ListID: 1,
}
err := task.Update(s, u)
assert.NoError(t, err)
err = s.Commit()
assert.NoError(t, err)
db.AssertCount(t, "task_reminders", builder.Eq{"task_id": 1}, 1)
})
}
func TestTask_Delete(t *testing.T) {