Author books API: use a single query with result and count

This commit is contained in:
2026-01-23 22:10:10 +01:00
parent 4ac0f4243d
commit cd2b8a93bb
6 changed files with 21 additions and 59 deletions

View File

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