Add integration test for search query
This commit is contained in:
parent
ca30800e6a
commit
364198ba4a
4 changed files with 32 additions and 1 deletions
2
Gopkg.lock
generated
2
Gopkg.lock
generated
|
@ -45,7 +45,7 @@
|
|||
branch = "master"
|
||||
name = "github.com/miniflux/miniflux-go"
|
||||
packages = ["."]
|
||||
revision = "cfb76c59831603c2b57e03356e9241facfa9834e"
|
||||
revision = "7b8d54a221db7b3e049f63e302ebbcc7d6a8d6be"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/tdewolff/minify"
|
||||
|
|
|
@ -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)
|
||||
|
|
4
vendor/github.com/miniflux/miniflux-go/client.go
generated
vendored
4
vendor/github.com/miniflux/miniflux-go/client.go
generated
vendored
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
1
vendor/github.com/miniflux/miniflux-go/miniflux.go
generated
vendored
1
vendor/github.com/miniflux/miniflux-go/miniflux.go
generated
vendored
|
@ -166,6 +166,7 @@ type Filter struct {
|
|||
After int64
|
||||
BeforeEntryID int64
|
||||
AfterEntryID int64
|
||||
Search string
|
||||
}
|
||||
|
||||
// EntryResultSet represents the response when fetching entries.
|
||||
|
|
Loading…
Add table
Reference in a new issue