Improved unit tests
the build failed
Details
the build failed
Details
This commit is contained in:
parent
7ddbec7a6f
commit
aa5b510424
|
@ -77,4 +77,42 @@ func TestAddOrUpdateAuthor(t *testing.T) {
|
||||||
err = DeleteAuthorByID(0)
|
err = DeleteAuthorByID(0)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.True(t, IsErrIDCannotBeZero(err))
|
assert.True(t, IsErrIDCannotBeZero(err))
|
||||||
|
|
||||||
|
// =======================
|
||||||
|
// Testing without a table
|
||||||
|
|
||||||
|
// Drop the table to see it fail
|
||||||
|
x.DropTables(Author{})
|
||||||
|
|
||||||
|
// Test inserting
|
||||||
|
_, err = AddOrUpdateAuthor(Author{Forename:"ff", Lastname: "fff"})
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
// Test updating
|
||||||
|
_, err = AddOrUpdateAuthor(Author{ID: 3, Forename:"ff", Lastname: "fff"})
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
// Delete from some nonexistent
|
||||||
|
err = DeleteAuthorByID(3)
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
// And get from nonexistant
|
||||||
|
_, err = ListAuthors("")
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
//Aaaaaaaaaand recreate it
|
||||||
|
x.Sync(Author{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetAuthorsByBook(t *testing.T) {
|
||||||
|
// Create test database
|
||||||
|
assert.NoError(t, PrepareTestDatabase())
|
||||||
|
|
||||||
|
// Drop the table to see it fail
|
||||||
|
x.DropTables(AuthorBook{})
|
||||||
|
_, err := GetAuthorsByBook(Book{ID:1})
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
//Aaaaaaaaaand recreate it
|
||||||
|
x.Sync(AuthorBook{})
|
||||||
|
}
|
Loading…
Reference in New Issue