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

Add integration test for export API endpoint

This commit is contained in:
Frédéric Guillot 2018-01-12 18:16:51 -08:00
parent 4aec2453f4
commit 631e0a2e20
5 changed files with 62 additions and 9 deletions

View file

@ -40,6 +40,21 @@ func main() {
return
}
fmt.Println(feeds)
// Backup to opml file.
opml, err := client.Export()
if err != nil {
fmt.Println(err)
return
}
err = ioutil.WriteFile("opml.xml", opml, 0644)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("backup done!")
}
```

View file

@ -7,6 +7,7 @@ package miniflux
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"strconv"
)
@ -213,6 +214,22 @@ func (c *Client) Feeds() (Feeds, error) {
return feeds, nil
}
// Export creates OPML file.
func (c *Client) Export() ([]byte, error) {
body, err := c.request.Get("/v1/export")
if err != nil {
return nil, err
}
defer body.Close()
opml, err := ioutil.ReadAll(body)
if err != nil {
return nil, err
}
return opml, nil
}
// Feed gets a feed.
func (c *Client) Feed(feedID int64) (*Feed, error) {
body, err := c.request.Get(fmt.Sprintf("/v1/feeds/%d", feedID))

View file

@ -18,14 +18,16 @@ const (
// User represents a user in the system.
type User struct {
ID int64 `json:"id"`
Username string `json:"username"`
Password string `json:"password,omitempty"`
IsAdmin bool `json:"is_admin"`
Theme string `json:"theme"`
Language string `json:"language"`
Timezone string `json:"timezone"`
LastLoginAt *time.Time `json:"last_login_at"`
ID int64 `json:"id"`
Username string `json:"username"`
Password string `json:"password,omitempty"`
IsAdmin bool `json:"is_admin"`
Theme string `json:"theme"`
Language string `json:"language"`
Timezone string `json:"timezone"`
EntryDirection string `json:"entry_sorting_direction"`
LastLoginAt *time.Time `json:"last_login_at"`
Extra map[string]string `json:"extra"`
}
func (u User) String() string {