1
0

Testing improvements (#666)

Change method names to avoid doubling db

Assert team test exists

Assert team member test exists

Assert task test exists

Assert task relation test exists

Assert task comment test exists

Better tests for team namespaces

Assert exists in namespace users tests

Assert exists in namespace tests

Assert exists in user list tests

Assert exists in list tests

Better team list tests

Assert label tests exist in db

Assert label task tests exist in db

Assert label task tests exist in db

Assert kanban tests exist in db

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/666
Co-Authored-By: konrad <konrad@kola-entertainments.de>
Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad
2020-09-27 15:45:17 +00:00
parent dd5d64da3e
commit 64d125afd9
16 changed files with 492 additions and 165 deletions

View File

@ -73,8 +73,8 @@ func InitTestFixtures(tablenames ...string) (err error) {
return nil
}
// AssertDBExists checks and asserts the existence of certain entries in the db
func AssertDBExists(t *testing.T, table string, values map[string]interface{}, custom bool) {
// AssertExists checks and asserts the existence of certain entries in the db
func AssertExists(t *testing.T, table string, values map[string]interface{}, custom bool) {
var exists bool
var err error
v := make(map[string]interface{})
@ -94,8 +94,8 @@ func AssertDBExists(t *testing.T, table string, values map[string]interface{}, c
assert.True(t, exists, fmt.Sprintf("Entries %v do not exist in table %s", values, table))
}
// AssertDBMissing checks and asserts the nonexiste nce of certain entries in the db
func AssertDBMissing(t *testing.T, table string, values map[string]interface{}) {
// AssertMissing checks and asserts the nonexiste nce of certain entries in the db
func AssertMissing(t *testing.T, table string, values map[string]interface{}) {
v := make(map[string]interface{})
exists, err := x.Table(table).Where(values).Exist(&v)
assert.NoError(t, err, fmt.Sprintf("Failed to assert entries don't exist in db, error was: %s", err))