mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Add integration tests for entries
This commit is contained in:
parent
51f7775466
commit
8781648af9
9 changed files with 356 additions and 43 deletions
14
vendor/github.com/lib/pq/.travis.yml
generated
vendored
14
vendor/github.com/lib/pq/.travis.yml
generated
vendored
|
@ -16,7 +16,7 @@ env:
|
|||
- PQGOSSLTESTS=1
|
||||
- PQSSLCERTTEST_PATH=$PWD/certs
|
||||
- PGHOST=127.0.0.1
|
||||
- MEGACHECK_VERSION=2017.1
|
||||
- MEGACHECK_VERSION=2017.2.1
|
||||
matrix:
|
||||
- PGVERSION=10
|
||||
- PGVERSION=9.6
|
||||
|
@ -46,15 +46,13 @@ script:
|
|||
- >
|
||||
goimports -d -e $(find -name '*.go') | awk '{ print } END { exit NR == 0 ? 0 : 1 }'
|
||||
- go vet ./...
|
||||
# For compatibility with Go 1.5, launch only if megacheck is present,
|
||||
# ignore SA1019 (deprecation warnings) in conn_test.go (we have to use the
|
||||
# deprecated driver.Execer and driver.Queryer interfaces) and S1024
|
||||
# (time.Until) everywhere.
|
||||
# For compatibility with Go 1.5, launch only if megacheck is present.
|
||||
- >
|
||||
which megacheck > /dev/null
|
||||
&& megacheck -ignore 'github.com/lib/pq/conn_test.go:SA1019 github.com/lib/pq/*.go:S1024' ./...
|
||||
which megacheck > /dev/null && megacheck -go 1.5 ./...
|
||||
|| echo 'megacheck is not supported, skipping check'
|
||||
# For compatibility with Go 1.5, launch only if golint is present.
|
||||
- which golint > /dev/null && golint ./... || echo 'golint is not supported, skipping check'
|
||||
- >
|
||||
which golint > /dev/null && golint ./...
|
||||
|| echo 'golint is not supported, skipping check'
|
||||
- PQTEST_BINARY_PARAMETERS=no go test -race -v ./...
|
||||
- PQTEST_BINARY_PARAMETERS=yes go test -race -v ./...
|
||||
|
|
79
vendor/github.com/miniflux/miniflux-go/client.go
generated
vendored
79
vendor/github.com/miniflux/miniflux-go/client.go
generated
vendored
|
@ -196,7 +196,7 @@ func (c *Client) Feeds() (Feeds, error) {
|
|||
return feeds, nil
|
||||
}
|
||||
|
||||
// Feed gets a new feed.
|
||||
// Feed gets a feed.
|
||||
func (c *Client) Feed(feedID int64) (*Feed, error) {
|
||||
body, err := c.request.Get(fmt.Sprintf("/v1/feeds/%d", feedID))
|
||||
if err != nil {
|
||||
|
@ -291,35 +291,28 @@ func (c *Client) Entry(feedID, entryID int64) (*Entry, error) {
|
|||
return entry, nil
|
||||
}
|
||||
|
||||
// Entries gets feed entries.
|
||||
func (c *Client) Entries(feedID int64, filter *Filter) (*EntryResultSet, error) {
|
||||
path := fmt.Sprintf("/v1/feeds/%d/entries", feedID)
|
||||
// Entries fetch entries.
|
||||
func (c *Client) Entries(filter *Filter) (*EntryResultSet, error) {
|
||||
path := buildFilterQueryString("/v1/entries", filter)
|
||||
|
||||
if filter != nil {
|
||||
values := url.Values{}
|
||||
|
||||
if filter.Status != "" {
|
||||
values.Set("status", filter.Status)
|
||||
}
|
||||
|
||||
if filter.Direction != "" {
|
||||
values.Set("direction", filter.Direction)
|
||||
}
|
||||
|
||||
if filter.Order != "" {
|
||||
values.Set("order", filter.Order)
|
||||
}
|
||||
|
||||
if filter.Limit != 0 {
|
||||
values.Set("limit", strconv.Itoa(filter.Limit))
|
||||
}
|
||||
|
||||
if filter.Offset != 0 {
|
||||
values.Set("offset", strconv.Itoa(filter.Offset))
|
||||
}
|
||||
|
||||
path = fmt.Sprintf("%s?%s", path, values.Encode())
|
||||
body, err := c.request.Get(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer body.Close()
|
||||
|
||||
var result EntryResultSet
|
||||
decoder := json.NewDecoder(body)
|
||||
if err := decoder.Decode(&result); err != nil {
|
||||
return nil, fmt.Errorf("miniflux: response error (%v)", err)
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// FeedEntries fetch feed entries.
|
||||
func (c *Client) FeedEntries(feedID int64, filter *Filter) (*EntryResultSet, error) {
|
||||
path := buildFilterQueryString(fmt.Sprintf("/v1/feeds/%d/entries", feedID), filter)
|
||||
|
||||
body, err := c.request.Get(path)
|
||||
if err != nil {
|
||||
|
@ -356,3 +349,33 @@ func (c *Client) UpdateEntries(entryIDs []int64, status string) error {
|
|||
func NewClient(endpoint, username, password string) *Client {
|
||||
return &Client{request: &request{endpoint: endpoint, username: username, password: password}}
|
||||
}
|
||||
|
||||
func buildFilterQueryString(path string, filter *Filter) string {
|
||||
if filter != nil {
|
||||
values := url.Values{}
|
||||
|
||||
if filter.Status != "" {
|
||||
values.Set("status", filter.Status)
|
||||
}
|
||||
|
||||
if filter.Direction != "" {
|
||||
values.Set("direction", filter.Direction)
|
||||
}
|
||||
|
||||
if filter.Order != "" {
|
||||
values.Set("order", filter.Order)
|
||||
}
|
||||
|
||||
if filter.Limit >= 0 {
|
||||
values.Set("limit", strconv.Itoa(filter.Limit))
|
||||
}
|
||||
|
||||
if filter.Offset >= 0 {
|
||||
values.Set("offset", strconv.Itoa(filter.Offset))
|
||||
}
|
||||
|
||||
path = fmt.Sprintf("%s?%s", path, values.Encode())
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue