Browse Source

Add integration test for search query

Frédéric Guillot 7 years ago
parent
commit
364198ba4a

+ 1 - 1
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"

+ 26 - 0
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)

+ 4 - 0
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())
 	}
 

+ 1 - 0
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.