1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

test(api): add integration test for fetching categories with counters

This commit is contained in:
Frédéric Guillot 2025-08-18 20:00:15 -07:00
parent 49575c8902
commit c105b14f58
2 changed files with 58 additions and 0 deletions

View file

@ -276,6 +276,22 @@ func (c *Client) Categories() (Categories, error) {
return categories, nil
}
// CategoriesWithCounters fetches the categories with their respective feed and unread counts.
func (c *Client) CategoriesWithCounters() (Categories, error) {
body, err := c.request.Get("/v1/categories?counts=true")
if err != nil {
return nil, err
}
defer body.Close()
var categories Categories
if err := json.NewDecoder(body).Decode(&categories); err != nil {
return nil, fmt.Errorf("miniflux: response error (%v)", err)
}
return categories, nil
}
// CreateCategory creates a new category.
func (c *Client) CreateCategory(title string) (*Category, error) {
body, err := c.request.Post("/v1/categories", &CategoryCreationRequest{