Author books API: use a single query with result and count
This commit is contained in:
@@ -71,22 +71,3 @@ func TestGetReadingBooksCountHandler_Demo(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, 2, c.Count)
|
||||
}
|
||||
|
||||
func TestGetAuthorsBooksCountHandler_Demo(t *testing.T) {
|
||||
router := testutils.TestSetup()
|
||||
|
||||
token := testutils.ConnectDemoUser(router)
|
||||
|
||||
req, _ := http.NewRequest("GET", "/author/1/books/count", nil)
|
||||
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
router.ServeHTTP(w, req)
|
||||
|
||||
var c countResponse
|
||||
err := json.Unmarshal(w.Body.Bytes(), &c)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.Equal(t, 3, c.Count)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user