Added Unit tests for quantity

This commit is contained in:
konrad 2018-01-16 15:58:16 +01:00 committed by kolaente
parent f4b8d07d0e
commit a809cbd485
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 13 additions and 0 deletions

View File

@ -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)