From a809cbd485e2265fd98149090abbe1bcff1ac509 Mon Sep 17 00:00:00 2001 From: konrad Date: Tue, 16 Jan 2018 15:58:16 +0100 Subject: [PATCH] Added Unit tests for quantity --- models/book_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/models/book_test.go b/models/book_test.go index 448729b..ce696b7 100644 --- a/models/book_test.go +++ b/models/book_test.go @@ -105,6 +105,19 @@ func TestAddOrUpdateBook(t *testing.T) { // (ID, Created, Updated), this would fail if we'd just directly compared authorsbybook and testbook.Authors assert.Equal(t, len(authorsbybook), len(testbook.Authors)) + // Test Quantity + qty1, err := book1.getQuantity() + assert.NoError(t, err) + assert.Equal(t, book1.Quantity, qty1) + + // Update the quantity and check again + err = book1.setQuantity(int64(99)) + assert.NoError(t, err) + + qty2, err := book1.getQuantity() + assert.NoError(t, err) + assert.Equal(t, int64(99), qty2) + // Delete the book err = DeleteBookByID(book1.ID) assert.NoError(t, err)