From 364198ba4a32f6123bd72f44c2aefc03b4a669f2 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 7 Jul 2018 12:02:59 -0700 Subject: Add integration test for search query --- Gopkg.lock | 2 +- integration_test.go | 26 ++++++++++++++++++++++ vendor/github.com/miniflux/miniflux-go/client.go | 4 ++++ vendor/github.com/miniflux/miniflux-go/miniflux.go | 1 + 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Gopkg.lock b/Gopkg.lock index c05c889..7a71ee0 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -45,7 +45,7 @@ branch = "master" name = "github.com/miniflux/miniflux-go" packages = ["."] - revision = "cfb76c59831603c2b57e03356e9241facfa9834e" + revision = "7b8d54a221db7b3e049f63e302ebbcc7d6a8d6be" [[projects]] name = "github.com/tdewolff/minify" diff --git a/integration_test.go b/integration_test.go index 30758a9..38ea60f 100644 --- a/integration_test.go +++ b/integration_test.go @@ -1091,6 +1091,32 @@ func TestGetAllEntries(t *testing.T) { } } +func TestSearchEntries(t *testing.T) { + client := createClient(t) + categories, err := client.Categories() + if err != nil { + t.Fatal(err) + } + + feedID, err := client.CreateFeed("https://github.com/miniflux/miniflux/releases.atom", categories[0].ID) + if err != nil { + t.Fatal(err) + } + + if feedID == 0 { + t.Fatalf(`Invalid feed ID, got %q`, feedID) + } + + results, err := client.Entries(&miniflux.Filter{Search: "2.0.8"}) + if err != nil { + t.Fatal(err) + } + + if results.Total != 1 { + t.Fatalf(`We should have only one entry instead of %d`, results.Total) + } +} + func TestInvalidFilters(t *testing.T) { client := createClient(t) createFeed(t, client) diff --git a/vendor/github.com/miniflux/miniflux-go/client.go b/vendor/github.com/miniflux/miniflux-go/client.go index 924fe49..4e3742e 100644 --- a/vendor/github.com/miniflux/miniflux-go/client.go +++ b/vendor/github.com/miniflux/miniflux-go/client.go @@ -497,6 +497,10 @@ func buildFilterQueryString(path string, filter *Filter) string { values.Set("starred", "1") } + if filter.Search != "" { + values.Set("search", filter.Search) + } + path = fmt.Sprintf("%s?%s", path, values.Encode()) } diff --git a/vendor/github.com/miniflux/miniflux-go/miniflux.go b/vendor/github.com/miniflux/miniflux-go/miniflux.go index 08e4d55..660fb10 100644 --- a/vendor/github.com/miniflux/miniflux-go/miniflux.go +++ b/vendor/github.com/miniflux/miniflux-go/miniflux.go @@ -166,6 +166,7 @@ type Filter struct { After int64 BeforeEntryID int64 AfterEntryID int64 + Search string } // EntryResultSet represents the response when fetching entries. -- cgit v1.2.3