Added Unit tests for quantity
This commit is contained in:
parent
f4b8d07d0e
commit
a809cbd485
|
@ -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
|
// (ID, Created, Updated), this would fail if we'd just directly compared authorsbybook and testbook.Authors
|
||||||
assert.Equal(t, len(authorsbybook), len(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
|
// Delete the book
|
||||||
err = DeleteBookByID(book1.ID)
|
err = DeleteBookByID(book1.ID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
Loading…
Reference in New Issue