diff options
author | Frédéric Guillot <fred@miniflux.net> | 2017-11-25 16:53:51 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2017-11-25 16:53:51 -0800 |
commit | 39b03cc393da657b11dbf25e51e2495f8739e491 (patch) | |
tree | 0231ec313a78453a8fccbac73919f25cd9cf598a /integration_test.go | |
parent | f072439b79ff6a003810a337664961865fefa755 (diff) |
Add integration tests for feed creation
Diffstat (limited to 'integration_test.go')
-rw-r--r-- | integration_test.go | 74 |
1 files changed, 71 insertions, 3 deletions
diff --git a/integration_test.go b/integration_test.go index 9d7002d..848a695 100644 --- a/integration_test.go +++ b/integration_test.go @@ -495,15 +495,83 @@ func TestDiscoverSubscriptions(t *testing.T) { } if subscriptions[0].Title != "Feed" { - t.Fatalf(`Invalid userID, got "%v" instead of "%v"`, subscriptions[0].Title, "Feed") + t.Fatalf(`Invalid feed title, got "%v" instead of "%v"`, subscriptions[0].Title, "Feed") } if subscriptions[0].Type != "atom" { - t.Fatalf(`Invalid userID, got "%v" instead of "%v"`, subscriptions[0].Type, "atom") + t.Fatalf(`Invalid feed type, got "%v" instead of "%v"`, subscriptions[0].Type, "atom") } if subscriptions[0].URL != "https://miniflux.net/feed" { - t.Fatalf(`Invalid userID, got "%v" instead of "%v"`, subscriptions[0].URL, "https://miniflux.net/feed") + t.Fatalf(`Invalid feed URL, got "%v" instead of "%v"`, subscriptions[0].URL, "https://miniflux.net/feed") + } +} + +func TestCreateFeed(t *testing.T) { + username := getRandomUsername() + client := miniflux.NewClient(testBaseURL, testAdminUsername, testAdminPassword) + _, err := client.CreateUser(username, testStandardPassword, false) + if err != nil { + t.Fatal(err) + } + + client = miniflux.NewClient(testBaseURL, username, testStandardPassword) + categories, err := client.Categories() + if err != nil { + t.Fatal(err) + } + + feedID, err := client.CreateFeed("https://miniflux.net/feed", categories[0].ID) + if err != nil { + t.Fatal(err) + } + + if feedID == 0 { + t.Fatalf(`Invalid feed ID, got "%v"`, feedID) + } +} + +func TestCannotCreateDuplicatedFeed(t *testing.T) { + username := getRandomUsername() + client := miniflux.NewClient(testBaseURL, testAdminUsername, testAdminPassword) + _, err := client.CreateUser(username, testStandardPassword, false) + if err != nil { + t.Fatal(err) + } + + client = miniflux.NewClient(testBaseURL, username, testStandardPassword) + categories, err := client.Categories() + if err != nil { + t.Fatal(err) + } + + feedID, err := client.CreateFeed("https://miniflux.net/feed", categories[0].ID) + if err != nil { + t.Fatal(err) + } + + if feedID == 0 { + t.Fatalf(`Invalid feed ID, got "%v"`, feedID) + } + + _, err = client.CreateFeed("https://miniflux.net/feed", categories[0].ID) + if err == nil { + t.Fatal(`Duplicated feeds should not be allowed`) + } +} + +func TestCreateFeedWithInexistingCategory(t *testing.T) { + username := getRandomUsername() + client := miniflux.NewClient(testBaseURL, testAdminUsername, testAdminPassword) + _, err := client.CreateUser(username, testStandardPassword, false) + if err != nil { + t.Fatal(err) + } + + client = miniflux.NewClient(testBaseURL, username, testStandardPassword) + _, err = client.CreateFeed("https://miniflux.net/feed", -1) + if err == nil { + t.Fatal(`Feeds should not be created with inexisting category`) } } |