aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2017-11-26 15:07:59 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2017-11-26 15:07:59 -0800
commit8781648af9f730d8bd1a7d9c395c1f28f9058716 (patch)
treea6c0c68a6864c56b5c35401c3e748310e5eafe80 /vendor
parent51f77754660ddcd29f61be293a8e405d8cd3ba18 (diff)
Add integration tests for entries
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/lib/pq/.travis.yml14
-rw-r--r--vendor/github.com/miniflux/miniflux-go/client.go75
2 files changed, 55 insertions, 34 deletions
diff --git a/vendor/github.com/lib/pq/.travis.yml b/vendor/github.com/lib/pq/.travis.yml
index 01468f0..4e34e88 100644
--- a/vendor/github.com/lib/pq/.travis.yml
+++ b/vendor/github.com/lib/pq/.travis.yml
@@ -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 ./...
diff --git a/vendor/github.com/miniflux/miniflux-go/client.go b/vendor/github.com/miniflux/miniflux-go/client.go
index 6a5f678..b43b8a9 100644
--- a/vendor/github.com/miniflux/miniflux-go/client.go
+++ b/vendor/github.com/miniflux/miniflux-go/client.go
@@ -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)
- }
+ body, err := c.request.Get(path)
+ if err != nil {
+ return nil, err
+ }
+ defer body.Close()
- if filter.Limit != 0 {
- values.Set("limit", strconv.Itoa(filter.Limit))
- }
+ var result EntryResultSet
+ decoder := json.NewDecoder(body)
+ if err := decoder.Decode(&result); err != nil {
+ return nil, fmt.Errorf("miniflux: response error (%v)", err)
+ }
- if filter.Offset != 0 {
- values.Set("offset", strconv.Itoa(filter.Offset))
- }
+ return &result, nil
+}
- path = fmt.Sprintf("%s?%s", path, values.Encode())
- }
+// 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
+}