aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2019-11-17 22:53:11 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2019-11-17 23:05:22 -0800
commite878dca3d74e1b8644d56e4f717b0a8e0362e888 (patch)
tree3a352dcc9a19244d7ff683f80a725cd28b21a471 /tests
parentfad9ad2be4fc800f8710e2a498cc8f536af8827c (diff)
Add API parameter to filter entries by category
Diffstat (limited to 'tests')
-rw-r--r--tests/entry_test.go36
-rw-r--r--tests/subscription_test.go4
-rw-r--r--tests/tests.go15
3 files changed, 45 insertions, 10 deletions
diff --git a/tests/entry_test.go b/tests/entry_test.go
index ba22bb9..fa887b0 100644
--- a/tests/entry_test.go
+++ b/tests/entry_test.go
@@ -93,6 +93,40 @@ func TestGetAllEntries(t *testing.T) {
}
}
+func TestFilterEntriesByCategory(t *testing.T) {
+ client := createClient(t)
+ category, err := client.CreateCategory("Test Filter by Category")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ feedID, err := client.CreateFeed(testFeedURL, category.ID)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if feedID == 0 {
+ t.Fatalf(`Invalid feed ID, got %q`, feedID)
+ }
+
+ results, err := client.Entries(&miniflux.Filter{CategoryID: category.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if results.Total == 0 {
+ t.Fatalf(`We should have more than one entry`)
+ }
+
+ if results.Entries[0].Feed.Category == nil {
+ t.Fatalf(`The entry feed category should not be nil`)
+ }
+
+ if results.Entries[0].Feed.Category.ID != category.ID {
+ t.Errorf(`Entries should be filtered by category_id=%d`, category.ID)
+ }
+}
+
func TestSearchEntries(t *testing.T) {
client := createClient(t)
categories, err := client.Categories()
@@ -100,7 +134,7 @@ func TestSearchEntries(t *testing.T) {
t.Fatal(err)
}
- feedID, err := client.CreateFeed("https://miniflux.app/feed.xml", categories[0].ID)
+ feedID, err := client.CreateFeed(testFeedURL, categories[0].ID)
if err != nil {
t.Fatal(err)
}
diff --git a/tests/subscription_test.go b/tests/subscription_test.go
index 5d98cc4..dd4d3d5 100644
--- a/tests/subscription_test.go
+++ b/tests/subscription_test.go
@@ -21,8 +21,8 @@ func TestDiscoverSubscriptions(t *testing.T) {
t.Fatalf(`Invalid number of subscriptions, got "%v" instead of "%v"`, len(subscriptions), 2)
}
- if subscriptions[0].Title != testFeedTitle {
- t.Fatalf(`Invalid feed title, got "%v" instead of "%v"`, subscriptions[0].Title, testFeedTitle)
+ if subscriptions[0].Title != testSubscriptionTitle {
+ t.Fatalf(`Invalid feed title, got "%v" instead of "%v"`, subscriptions[0].Title, testSubscriptionTitle)
}
if subscriptions[0].Type != "atom" {
diff --git a/tests/tests.go b/tests/tests.go
index 8183327..afc5ef0 100644
--- a/tests/tests.go
+++ b/tests/tests.go
@@ -15,13 +15,14 @@ import (
)
const (
- testBaseURL = "http://127.0.0.1:8080/"
- testAdminUsername = "admin"
- testAdminPassword = "test123"
- testStandardPassword = "secret"
- testFeedURL = "https://github.com/miniflux/miniflux/commits/master.atom"
- testFeedTitle = "Recent Commits to miniflux:master"
- testWebsiteURL = "https://github.com/miniflux/miniflux/commits/master"
+ testBaseURL = "http://127.0.0.1:8080/"
+ testAdminUsername = "admin"
+ testAdminPassword = "test123"
+ testStandardPassword = "secret"
+ testFeedURL = "https://miniflux.app/feed.xml"
+ testFeedTitle = "Miniflux"
+ testSubscriptionTitle = "Miniflux Releases"
+ testWebsiteURL = "https://miniflux.app/"
)
func getRandomUsername() string {