Assert label tests exist in db

Signed-off-by: kolaente <k@knt.li>
This commit is contained in:
kolaente 2020-09-27 13:05:52 +02:00
parent 659045e351
commit 2e55c48ece
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 19 additions and 0 deletions

View File

@ -314,6 +314,14 @@ func TestLabel_Create(t *testing.T) {
if err := l.Create(tt.args.a); (err != nil) != tt.wantErr {
t.Errorf("Label.Create() error = %v, wantErr %v", err, tt.wantErr)
}
if !tt.wantErr {
db.AssertDBExists(t, "labels", map[string]interface{}{
"id": l.ID,
"title": l.Title,
"description": l.Description,
"hex_color": l.HexColor,
}, false)
}
})
}
}
@ -396,6 +404,12 @@ func TestLabel_Update(t *testing.T) {
if err := l.Update(); (err != nil) != tt.wantErr {
t.Errorf("Label.Update() error = %v, wantErr %v", err, tt.wantErr)
}
if !tt.wantErr && !tt.wantForbidden {
db.AssertDBExists(t, "labels", map[string]interface{}{
"id": tt.fields.ID,
"title": tt.fields.Title,
}, false)
}
})
}
}
@ -474,6 +488,11 @@ func TestLabel_Delete(t *testing.T) {
if err := l.Delete(); (err != nil) != tt.wantErr {
t.Errorf("Label.Delete() error = %v, wantErr %v", err, tt.wantErr)
}
if !tt.wantErr && !tt.wantForbidden {
db.AssertDBMissing(t, "labels", map[string]interface{}{
"id": l.ID,
})
}
})
}
}