1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Add integration tests for feed creation

This commit is contained in:
Frédéric Guillot 2017-11-25 16:53:51 -08:00
parent f072439b79
commit 39b03cc393
46 changed files with 860 additions and 37 deletions

View file

@ -34,7 +34,7 @@ func main() {
client := miniflux.NewClient("https://api.example.org", "admin", "secret")
// Fetch all feeds.
feeds, err := userClient.Feeds()
feeds, err := client.Feeds()
if err != nil {
fmt.Println(err)
return

View file

@ -214,23 +214,27 @@ func (c *Client) Feed(feedID int64) (*Feed, error) {
}
// CreateFeed creates a new feed.
func (c *Client) CreateFeed(url string, categoryID int64) (*Feed, error) {
func (c *Client) CreateFeed(url string, categoryID int64) (int64, error) {
body, err := c.request.Post("/v1/feeds", map[string]interface{}{
"feed_url": url,
"category_id": categoryID,
})
if err != nil {
return nil, err
return 0, err
}
defer body.Close()
var feed *Feed
decoder := json.NewDecoder(body)
if err := decoder.Decode(&feed); err != nil {
return nil, fmt.Errorf("miniflux: response error (%v)", err)
type result struct {
FeedID int64 `json:"feed_id"`
}
return feed, nil
var r result
decoder := json.NewDecoder(body)
if err := decoder.Decode(&r); err != nil {
return 0, fmt.Errorf("miniflux: response error (%v)", err)
}
return r.FeedID, nil
}
// UpdateFeed updates a feed.