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

@ -20,6 +20,7 @@ import (
"fmt"
"os"
"testing"
"xorm.io/builder"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
@ -102,3 +103,10 @@ func AssertMissing(t *testing.T, table string, values map[string]interface{}) {
assert.NoError(t, err, fmt.Sprintf("Failed to assert entries don't exist in db, error was: %s", err))
assert.False(t, exists, fmt.Sprintf("Entries %v exist in table %s", values, table))
}
// AssertCount checks if a number of entries exists in the database
func AssertCount(t *testing.T, table string, where builder.Cond, count int64) {
dbCount, err := x.Table(table).Where(where).Count()
assert.NoError(t, err, fmt.Sprintf("Failed to assert count in db, error was: %s", err))
assert.Equal(t, count, dbCount, fmt.Sprintf("Found %d entries instead of expected %d in table %s", dbCount, count, table))
}