Fixed issue where querying empty collection returns an empty book record
This commit is contained in:
@@ -12,8 +12,8 @@ import (
|
||||
func TestFetchAllCollections_OK(t *testing.T) {
|
||||
status, res := testFetchCollections(t, "10", "0")
|
||||
assert.Equal(t, http.StatusOK, status)
|
||||
assert.Equal(t, int64(2), res.Count)
|
||||
assert.Equal(t, 2, len(res.Collections))
|
||||
assert.Equal(t, int64(3), res.Count)
|
||||
assert.Equal(t, 3, len(res.Collections))
|
||||
}
|
||||
|
||||
func testFetchCollections(t *testing.T, limit string, offset string) (int, dto.CollectionItemsGet) {
|
||||
|
||||
@@ -25,10 +25,18 @@ func TestGetCollection_Limit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCollection_Unauthorized(t *testing.T) {
|
||||
status, _ := testGetCollection(t, "4", "10", "0")
|
||||
status, _ := testGetCollection(t, "3", "10", "0")
|
||||
assert.Equal(t, http.StatusUnauthorized, status)
|
||||
}
|
||||
|
||||
func TestGetCollection_Empty(t *testing.T) {
|
||||
status, collection := testGetCollection(t, "4", "10", "0")
|
||||
assert.Equal(t, http.StatusOK, status)
|
||||
assert.Equal(t, "Empty", collection.Name)
|
||||
assert.Equal(t, 0, len(collection.Books))
|
||||
assert.Equal(t, int64(0), collection.Count)
|
||||
}
|
||||
|
||||
func testGetCollection(t *testing.T, id string, limit string, offset string) (int, dto.CollectionGet) {
|
||||
return testutils.TestFetchModel[dto.CollectionGet](t, "/ws/collection/"+id, limit, offset)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user