From d171d1f787494fa6dd4013aba77e5fe50344cfc1 Mon Sep 17 00:00:00 2001 From: konrad Date: Tue, 16 Jan 2018 14:55:45 +0100 Subject: [PATCH] Book unit test improvements --- models/book_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/models/book_test.go b/models/book_test.go index b9ff7c7..448729b 100644 --- a/models/book_test.go +++ b/models/book_test.go @@ -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)