Book unit test improvements

This commit is contained in:
konrad 2018-01-16 14:55:45 +01:00 committed by kolaente
parent df0482dac2
commit d171d1f787
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 9 additions and 0 deletions

View File

@ -96,6 +96,15 @@ func TestAddOrUpdateBook(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, testbook.Title, book1updated.Title)
// Get the authors for that book
authorsbybook, err := GetAuthorsByBook(book1)
assert.NoError(t, err)
// Check if they are the right ones
// Yes I know, this is not a good way to do this. But as we get additional information when selecting from the database
// (ID, Created, Updated), this would fail if we'd just directly compared authorsbybook and testbook.Authors
assert.Equal(t, len(authorsbybook), len(testbook.Authors))
// Delete the book
err = DeleteBookByID(book1.ID)
assert.NoError(t, err)