|
|
@@ -30,23 +30,23 @@ func TestGetAllFeedEntriesEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(results.Entries) == 0 {
|
|
|
- t.Fatalf(`Invalid number of entries, got %d`, len(results.Entries))
|
|
|
+ t.Fatal(`Expected entries, got none`)
|
|
|
}
|
|
|
|
|
|
if results.Total == 0 {
|
|
|
- t.Fatalf(`Invalid total, got %d`, results.Total)
|
|
|
+ t.Errorf(`Unexpected total: got %d, want nonzero`, results.Total)
|
|
|
}
|
|
|
|
|
|
if results.Entries[0].FeedID != feedID {
|
|
|
- t.Fatalf(`Invalid feedID, got %d`, results.Entries[0].FeedID)
|
|
|
+ t.Errorf(`Unexpected feed ID: got %d, want %d`, results.Entries[0].FeedID, feedID)
|
|
|
}
|
|
|
|
|
|
if results.Entries[0].Feed.FeedURL != fixture.FeedURL {
|
|
|
- t.Fatalf(`Invalid feed URL, got %q`, results.Entries[0].Feed.FeedURL)
|
|
|
+ t.Errorf(`Unexpected feed URL: got %q, want %q`, results.Entries[0].Feed.FeedURL, fixture.FeedURL)
|
|
|
}
|
|
|
|
|
|
if results.Entries[0].Title == "" {
|
|
|
- t.Fatalf(`Invalid title, got empty`)
|
|
|
+ t.Errorf(`Unexpected title: got %q, want nonempty`, results.Entries[0].Title)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -76,23 +76,23 @@ func TestGetAllCategoryEntriesEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(results.Entries) == 0 {
|
|
|
- t.Fatalf(`Invalid number of entries, got %d`, len(results.Entries))
|
|
|
+ t.Fatal(`Expected entries, got none`)
|
|
|
}
|
|
|
|
|
|
if results.Total == 0 {
|
|
|
- t.Fatalf(`Invalid total, got %d`, results.Total)
|
|
|
+ t.Errorf(`Unexpected total: got %d, want nonzero`, results.Total)
|
|
|
}
|
|
|
|
|
|
if results.Entries[0].FeedID != feedID {
|
|
|
- t.Fatalf(`Invalid feedID, got %d`, results.Entries[0].FeedID)
|
|
|
+ t.Errorf(`Unexpected feed ID: got %d, want %d`, results.Entries[0].FeedID, feedID)
|
|
|
}
|
|
|
|
|
|
if results.Entries[0].Feed.FeedURL != fixture.FeedURL {
|
|
|
- t.Fatalf(`Invalid feed URL, got %q`, results.Entries[0].Feed.FeedURL)
|
|
|
+ t.Errorf(`Unexpected feed URL: got %q, want %q`, results.Entries[0].Feed.FeedURL, fixture.FeedURL)
|
|
|
}
|
|
|
|
|
|
if results.Entries[0].Title == "" {
|
|
|
- t.Fatalf(`Invalid title, got empty`)
|
|
|
+ t.Errorf(`Unexpected title: got %q, want nonempty`, results.Entries[0].Title)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -111,24 +111,24 @@ func TestGetAllEntriesEndpointWithFilter(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(feedEntries.Entries) != servertest.EntryCount {
|
|
|
- t.Fatalf(`Invalid number of entries, got %d instead of %d`, len(feedEntries.Entries), servertest.EntryCount)
|
|
|
+ t.Fatalf(`Unexpected number of entries: got %d, want %d`, len(feedEntries.Entries), servertest.EntryCount)
|
|
|
}
|
|
|
|
|
|
if feedEntries.Total != servertest.EntryCount {
|
|
|
- t.Fatalf(`Invalid total, got %d instead of %d`, feedEntries.Total, servertest.EntryCount)
|
|
|
+ t.Errorf(`Unexpected total: got %d, want %d`, feedEntries.Total, servertest.EntryCount)
|
|
|
}
|
|
|
|
|
|
if feedEntries.Entries[0].FeedID != feedID {
|
|
|
- t.Fatalf(`Invalid feedID, got %d`, feedEntries.Entries[0].FeedID)
|
|
|
+ t.Errorf(`Unexpected feed ID: got %d, want %d`, feedEntries.Entries[0].FeedID, feedID)
|
|
|
}
|
|
|
|
|
|
if feedEntries.Entries[0].Feed.FeedURL != fixture.FeedURL {
|
|
|
- t.Fatalf(`Invalid feed URL, got %q`, feedEntries.Entries[0].Feed.FeedURL)
|
|
|
+ t.Errorf(`Unexpected feed URL: got %q, want %q`, feedEntries.Entries[0].Feed.FeedURL, fixture.FeedURL)
|
|
|
}
|
|
|
|
|
|
// Entries are sorted by ascending publication date by default.
|
|
|
if feedEntries.Entries[0].Title != "Entry 1" {
|
|
|
- t.Fatalf(`Invalid title of the oldest entry, got %q`, feedEntries.Entries[0].Title)
|
|
|
+ t.Errorf(`Unexpected title of the oldest entry: got %q, want %q`, feedEntries.Entries[0].Title, "Entry 1")
|
|
|
}
|
|
|
|
|
|
emptyPage, err := regularUserClient.Entries(&miniflux.Filter{
|
|
|
@@ -141,11 +141,11 @@ func TestGetAllEntriesEndpointWithFilter(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(emptyPage.Entries) != 0 {
|
|
|
- t.Fatalf(`Expected no entries beyond the final page, got %d`, len(emptyPage.Entries))
|
|
|
+ t.Errorf(`Expected no entries beyond the final page, got %d`, len(emptyPage.Entries))
|
|
|
}
|
|
|
|
|
|
if emptyPage.Total != feedEntries.Total {
|
|
|
- t.Fatalf(`Expected total %d beyond the final page, got %d`, feedEntries.Total, emptyPage.Total)
|
|
|
+ t.Errorf(`Unexpected total beyond the final page: got %d, want %d`, emptyPage.Total, feedEntries.Total)
|
|
|
}
|
|
|
|
|
|
recentEntries, err := regularUserClient.Entries(&miniflux.Filter{Order: "published_at", Direction: "desc"})
|
|
|
@@ -154,11 +154,11 @@ func TestGetAllEntriesEndpointWithFilter(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(recentEntries.Entries) != servertest.EntryCount {
|
|
|
- t.Fatalf(`Invalid number of entries, got %d instead of %d`, len(recentEntries.Entries), servertest.EntryCount)
|
|
|
+ t.Fatalf(`Unexpected number of entries: got %d, want %d`, len(recentEntries.Entries), servertest.EntryCount)
|
|
|
}
|
|
|
|
|
|
if recentEntries.Entries[0].Title != "Entry 3" {
|
|
|
- t.Fatalf(`Invalid order, got %q instead of the most recent entry`, recentEntries.Entries[0].Title)
|
|
|
+ t.Errorf(`Unexpected most recent entry: got %q, want %q`, recentEntries.Entries[0].Title, "Entry 3")
|
|
|
}
|
|
|
|
|
|
searchedEntries, err := regularUserClient.Entries(&miniflux.Filter{Search: servertest.SearchTerm})
|
|
|
@@ -167,23 +167,23 @@ func TestGetAllEntriesEndpointWithFilter(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if searchedEntries.Total != 1 || len(searchedEntries.Entries) != 1 {
|
|
|
- t.Fatalf(`Invalid search results, got %d entries and total %d`, len(searchedEntries.Entries), searchedEntries.Total)
|
|
|
+ t.Fatalf(`Unexpected search results: got %d entries and total %d, want 1 and 1`, len(searchedEntries.Entries), searchedEntries.Total)
|
|
|
}
|
|
|
|
|
|
if searchedEntries.Entries[0].Title != "Entry 2" {
|
|
|
- t.Fatalf(`Invalid search result, got %q`, searchedEntries.Entries[0].Title)
|
|
|
+ t.Errorf(`Unexpected search result: got %q, want %q`, searchedEntries.Entries[0].Title, "Entry 2")
|
|
|
}
|
|
|
|
|
|
if _, err := regularUserClient.Entries(&miniflux.Filter{Status: "invalid"}); !errors.Is(err, miniflux.ErrBadRequest) {
|
|
|
- t.Fatalf(`Using invalid status should raise an error, got %v`, err)
|
|
|
+ t.Errorf(`Listing entries with an invalid status: got error %v, want %v`, err, miniflux.ErrBadRequest)
|
|
|
}
|
|
|
|
|
|
if _, err = regularUserClient.Entries(&miniflux.Filter{Direction: "invalid"}); !errors.Is(err, miniflux.ErrBadRequest) {
|
|
|
- t.Fatalf(`Using invalid direction should raise an error, got %v`, err)
|
|
|
+ t.Errorf(`Listing entries with an invalid direction: got error %v, want %v`, err, miniflux.ErrBadRequest)
|
|
|
}
|
|
|
|
|
|
if _, err = regularUserClient.Entries(&miniflux.Filter{Order: "invalid"}); !errors.Is(err, miniflux.ErrBadRequest) {
|
|
|
- t.Fatalf(`Using invalid order should raise an error, got %v`, err)
|
|
|
+ t.Errorf(`Listing entries with an invalid order: got error %v, want %v`, err, miniflux.ErrBadRequest)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -208,7 +208,7 @@ func TestGetGlobalEntriesEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if !feed.HideGlobally {
|
|
|
- t.Fatalf(`Expected feed to have globally_hidden set to true, was false.`)
|
|
|
+ t.Errorf(`Unexpected hide globally value: got %t, want %t`, feed.HideGlobally, true)
|
|
|
}
|
|
|
|
|
|
// Not filtering on GloballyVisible should return all entries.
|
|
|
@@ -218,7 +218,7 @@ func TestGetGlobalEntriesEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(feedEntries.Entries) == 0 {
|
|
|
- t.Fatalf(`Expected entries but response contained none.`)
|
|
|
+ t.Error(`Expected entries of the hidden feed, got none`)
|
|
|
}
|
|
|
|
|
|
// The feed is hidden globally, so this should be empty.
|
|
|
@@ -228,7 +228,7 @@ func TestGetGlobalEntriesEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(globallyVisibleEntries.Entries) != 0 {
|
|
|
- t.Fatalf(`Expected no entries, got %d`, len(globallyVisibleEntries.Entries))
|
|
|
+ t.Errorf(`Expected no globally visible entries, got %d`, len(globallyVisibleEntries.Entries))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -249,15 +249,15 @@ func TestGetEntryEndpoints(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entry.ID != entries[0].ID {
|
|
|
- t.Fatalf(`Invalid entryID, got %d`, entry.ID)
|
|
|
+ t.Errorf(`Unexpected entry ID: got %d, want %d`, entry.ID, entries[0].ID)
|
|
|
}
|
|
|
|
|
|
if entry.FeedID != feedID {
|
|
|
- t.Fatalf(`Invalid feedID, got %d`, entry.FeedID)
|
|
|
+ t.Errorf(`Unexpected feed ID: got %d, want %d`, entry.FeedID, feedID)
|
|
|
}
|
|
|
|
|
|
if entry.Feed.FeedURL != fixture.FeedURL {
|
|
|
- t.Fatalf(`Invalid feed URL, got %q`, entry.Feed.FeedURL)
|
|
|
+ t.Errorf(`Unexpected feed URL: got %q, want %q`, entry.Feed.FeedURL, fixture.FeedURL)
|
|
|
}
|
|
|
|
|
|
entry, err = regularUserClient.Entry(entries[0].ID)
|
|
|
@@ -266,7 +266,7 @@ func TestGetEntryEndpoints(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entry.ID != entries[0].ID {
|
|
|
- t.Fatalf(`Invalid entryID, got %d`, entry.ID)
|
|
|
+ t.Errorf(`Unexpected entry ID: got %d, want %d`, entry.ID, entries[0].ID)
|
|
|
}
|
|
|
|
|
|
entry, err = regularUserClient.CategoryEntry(entries[0].Feed.Category.ID, entries[0].ID)
|
|
|
@@ -275,7 +275,7 @@ func TestGetEntryEndpoints(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entry.ID != entries[0].ID {
|
|
|
- t.Fatalf(`Invalid entryID, got %d`, entry.ID)
|
|
|
+ t.Errorf(`Unexpected entry ID: got %d, want %d`, entry.ID, entries[0].ID)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -300,7 +300,7 @@ func TestUpdateEntryStatusEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entry.Status != miniflux.EntryStatusRead {
|
|
|
- t.Fatalf(`Invalid status, got %q`, entry.Status)
|
|
|
+ t.Errorf(`Unexpected status: got %q, want %q`, entry.Status, miniflux.EntryStatusRead)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -326,11 +326,11 @@ func TestUpdateEntriesStarredEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if !entry.Starred {
|
|
|
- t.Fatalf(`Expected entry to be starred`)
|
|
|
+ t.Errorf(`Unexpected starred flag: got %t, want %t`, entry.Starred, true)
|
|
|
}
|
|
|
|
|
|
if entry.Status != miniflux.EntryStatusUnread {
|
|
|
- t.Fatalf(`Expected status to remain unread, got %q`, entry.Status)
|
|
|
+ t.Errorf(`Unexpected status: got %q, want %q`, entry.Status, miniflux.EntryStatusUnread)
|
|
|
}
|
|
|
|
|
|
// Unstar the entry.
|
|
|
@@ -344,7 +344,7 @@ func TestUpdateEntriesStarredEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entry.Starred {
|
|
|
- t.Fatalf(`Expected entry to no longer be starred`)
|
|
|
+ t.Errorf(`Unexpected starred flag: got %t, want %t`, entry.Starred, false)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -362,15 +362,15 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if result.EntryIDs == nil {
|
|
|
- t.Fatal(`Entry IDs should not be nil`)
|
|
|
+ t.Error(`Expected an empty list of entry IDs, got nil`)
|
|
|
}
|
|
|
|
|
|
if len(result.EntryIDs) != 0 {
|
|
|
- t.Fatalf(`Expected no entry IDs for a new user, got %d`, len(result.EntryIDs))
|
|
|
+ t.Errorf(`Expected no entry IDs for a new user, got %d`, len(result.EntryIDs))
|
|
|
}
|
|
|
|
|
|
if result.Total != 0 {
|
|
|
- t.Fatalf(`Expected total to be 0 for a new user, got %d`, result.Total)
|
|
|
+ t.Errorf(`Unexpected total for a new user: got %d, want 0`, result.Total)
|
|
|
}
|
|
|
|
|
|
// Subscribe to a feed so there are entries.
|
|
|
@@ -385,11 +385,11 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(result.EntryIDs) != servertest.EntryCount {
|
|
|
- t.Fatalf(`Expected %d entry IDs, got %d`, servertest.EntryCount, len(result.EntryIDs))
|
|
|
+ t.Errorf(`Unexpected number of entry IDs: got %d, want %d`, len(result.EntryIDs), servertest.EntryCount)
|
|
|
}
|
|
|
|
|
|
if result.Total != servertest.EntryCount {
|
|
|
- t.Fatalf(`Expected total %d, got %d`, servertest.EntryCount, result.Total)
|
|
|
+ t.Errorf(`Unexpected total: got %d, want %d`, result.Total, servertest.EntryCount)
|
|
|
}
|
|
|
|
|
|
// Filter by status=unread: all entries should be unread initially.
|
|
|
@@ -399,7 +399,7 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(unreadResult.EntryIDs) != servertest.EntryCount {
|
|
|
- t.Fatalf(`Expected %d unread entry IDs, got %d`, servertest.EntryCount, len(unreadResult.EntryIDs))
|
|
|
+ t.Errorf(`Unexpected number of unread entry IDs: got %d, want %d`, len(unreadResult.EntryIDs), servertest.EntryCount)
|
|
|
}
|
|
|
|
|
|
// Mark one entry as read and verify status filter results update.
|
|
|
@@ -414,16 +414,16 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(unreadResult.EntryIDs) != servertest.EntryCount-1 {
|
|
|
- t.Fatalf(`Expected %d unread entry IDs after marking one as read, got %d`, servertest.EntryCount-1, len(unreadResult.EntryIDs))
|
|
|
+ t.Errorf(`Unexpected number of unread entry IDs after marking one as read: got %d, want %d`, len(unreadResult.EntryIDs), servertest.EntryCount-1)
|
|
|
}
|
|
|
|
|
|
if unreadResult.Total != servertest.EntryCount-1 {
|
|
|
- t.Fatalf(`Expected total %d after marking one as read, got %d`, servertest.EntryCount-1, unreadResult.Total)
|
|
|
+ t.Errorf(`Unexpected unread total after marking one as read: got %d, want %d`, unreadResult.Total, servertest.EntryCount-1)
|
|
|
}
|
|
|
|
|
|
for _, id := range unreadResult.EntryIDs {
|
|
|
if id == firstEntryID {
|
|
|
- t.Fatalf(`Entry ID %d should not appear in unread IDs after being marked as read`, firstEntryID)
|
|
|
+ t.Errorf(`Expected no entry %d in the unread entry IDs, got %v`, firstEntryID, unreadResult.EntryIDs)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -433,7 +433,7 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(readResult.EntryIDs) != 1 || readResult.EntryIDs[0] != firstEntryID {
|
|
|
- t.Fatalf(`Expected only entry %d in read results, got %v`, firstEntryID, readResult.EntryIDs)
|
|
|
+ t.Errorf(`Unexpected read entry IDs: got %v, want [%d]`, readResult.EntryIDs, firstEntryID)
|
|
|
}
|
|
|
|
|
|
// Pagination: limit=1 should return 1 entry but total reflects the full unread count.
|
|
|
@@ -443,11 +443,11 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(pagedResult.EntryIDs) != 1 {
|
|
|
- t.Fatalf(`Expected 1 entry ID with limit=1, got %d`, len(pagedResult.EntryIDs))
|
|
|
+ t.Fatalf(`Unexpected number of entry IDs with limit=1: got %d, want 1`, len(pagedResult.EntryIDs))
|
|
|
}
|
|
|
|
|
|
if pagedResult.Total != servertest.EntryCount-1 {
|
|
|
- t.Fatalf(`Expected total %d with limit=1, got %d`, servertest.EntryCount-1, pagedResult.Total)
|
|
|
+ t.Errorf(`Unexpected total with limit=1: got %d, want %d`, pagedResult.Total, servertest.EntryCount-1)
|
|
|
}
|
|
|
|
|
|
// offset=1 should skip the first entry.
|
|
|
@@ -457,11 +457,11 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(offsetResult.EntryIDs) != 1 {
|
|
|
- t.Fatalf(`Expected 1 entry ID with limit=1 offset=1, got %d`, len(offsetResult.EntryIDs))
|
|
|
+ t.Fatalf(`Unexpected number of entry IDs with limit=1 offset=1: got %d, want 1`, len(offsetResult.EntryIDs))
|
|
|
}
|
|
|
|
|
|
if offsetResult.EntryIDs[0] == pagedResult.EntryIDs[0] {
|
|
|
- t.Fatalf(`Entry at offset=1 should differ from offset=0, both returned %d`, offsetResult.EntryIDs[0])
|
|
|
+ t.Errorf(`Expected different entry IDs at offsets 0 and 1, got %d for both`, offsetResult.EntryIDs[0])
|
|
|
}
|
|
|
|
|
|
// Filter by starred=true: initially no starred entries.
|
|
|
@@ -471,7 +471,7 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(starredResult.EntryIDs) != 0 {
|
|
|
- t.Fatalf(`Expected no starred entry IDs for a new user, got %d`, len(starredResult.EntryIDs))
|
|
|
+ t.Errorf(`Expected no starred entry IDs before starring, got %d`, len(starredResult.EntryIDs))
|
|
|
}
|
|
|
|
|
|
// Star the first entry and verify it appears in starred results.
|
|
|
@@ -485,15 +485,15 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(starredResult.EntryIDs) != 1 {
|
|
|
- t.Fatalf(`Expected 1 starred entry ID, got %d`, len(starredResult.EntryIDs))
|
|
|
+ t.Fatalf(`Unexpected number of starred entry IDs: got %d, want 1`, len(starredResult.EntryIDs))
|
|
|
}
|
|
|
|
|
|
if starredResult.Total != 1 {
|
|
|
- t.Fatalf(`Expected total 1, got %d`, starredResult.Total)
|
|
|
+ t.Errorf(`Unexpected starred total: got %d, want 1`, starredResult.Total)
|
|
|
}
|
|
|
|
|
|
if starredResult.EntryIDs[0] != firstEntryID {
|
|
|
- t.Fatalf(`Expected starred entry ID %d, got %d`, firstEntryID, starredResult.EntryIDs[0])
|
|
|
+ t.Errorf(`Unexpected starred entry ID: got %d, want %d`, starredResult.EntryIDs[0], firstEntryID)
|
|
|
}
|
|
|
|
|
|
// starred=false should exclude the starred entry.
|
|
|
@@ -504,7 +504,7 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
|
|
|
for _, id := range notStarredResult.EntryIDs {
|
|
|
if id == firstEntryID {
|
|
|
- t.Fatalf(`Starred entry %d should not appear in starred=false results`, firstEntryID)
|
|
|
+ t.Errorf(`Expected no entry %d in the entry IDs that are not starred, got %v`, firstEntryID, notStarredResult.EntryIDs)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -515,11 +515,11 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(pagedStarred.EntryIDs) != 0 {
|
|
|
- t.Fatalf(`Expected 0 entry IDs with offset=1 past the only result, got %d`, len(pagedStarred.EntryIDs))
|
|
|
+ t.Errorf(`Expected no entry IDs past the only starred entry, got %d`, len(pagedStarred.EntryIDs))
|
|
|
}
|
|
|
|
|
|
if pagedStarred.Total != 1 {
|
|
|
- t.Fatalf(`Expected total 1 with offset past results, got %d`, pagedStarred.Total)
|
|
|
+ t.Errorf(`Unexpected starred total past the only entry: got %d, want 1`, pagedStarred.Total)
|
|
|
}
|
|
|
|
|
|
// Unstarring the entry should remove it from starred=true results.
|
|
|
@@ -533,17 +533,17 @@ func TestGetEntryIDsEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if len(starredResult.EntryIDs) != 0 {
|
|
|
- t.Fatalf(`Expected no starred entry IDs after unstarring, got %d`, len(starredResult.EntryIDs))
|
|
|
+ t.Errorf(`Expected no starred entry IDs after unstarring, got %d`, len(starredResult.EntryIDs))
|
|
|
}
|
|
|
|
|
|
if starredResult.Total != 0 {
|
|
|
- t.Fatalf(`Expected total 0 after unstarring, got %d`, starredResult.Total)
|
|
|
+ t.Errorf(`Unexpected starred total after unstarring: got %d, want 0`, starredResult.Total)
|
|
|
}
|
|
|
|
|
|
// An invalid status value should return 400.
|
|
|
_, err = regularUserClient.EntryIDs(&miniflux.EntryIDsFilter{Status: "maybe"})
|
|
|
if !errors.Is(err, miniflux.ErrBadRequest) {
|
|
|
- t.Fatalf(`Expected a bad request error for an invalid status parameter, got %v`, err)
|
|
|
+ t.Errorf(`Listing entry IDs with an invalid status: got error %v, want %v`, err, miniflux.ErrBadRequest)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -569,11 +569,11 @@ func TestUpdateEntryEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if updatedEntry.Title != "New title" {
|
|
|
- t.Errorf(`Invalid title, got %q`, updatedEntry.Title)
|
|
|
+ t.Errorf(`Unexpected title: got %q, want %q`, updatedEntry.Title, "New title")
|
|
|
}
|
|
|
|
|
|
if updatedEntry.Content != "New content" {
|
|
|
- t.Errorf(`Invalid content, got %q`, updatedEntry.Content)
|
|
|
+ t.Errorf(`Unexpected content: got %q, want %q`, updatedEntry.Content, "New content")
|
|
|
}
|
|
|
|
|
|
entry, err := regularUserClient.Entry(entryID)
|
|
|
@@ -582,11 +582,11 @@ func TestUpdateEntryEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entry.Title != "New title" {
|
|
|
- t.Errorf(`Invalid title, got %q`, entry.Title)
|
|
|
+ t.Errorf(`Unexpected title: got %q, want %q`, entry.Title, "New title")
|
|
|
}
|
|
|
|
|
|
if entry.Content != "New content" {
|
|
|
- t.Errorf(`Invalid content, got %q`, entry.Content)
|
|
|
+ t.Errorf(`Unexpected content: got %q, want %q`, entry.Content, "New content")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -611,13 +611,13 @@ func TestToggleStarredEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if !entry.Starred {
|
|
|
- t.Fatalf(`The entry should be starred`)
|
|
|
+ t.Errorf(`Unexpected starred flag: got %t, want %t`, entry.Starred, true)
|
|
|
}
|
|
|
|
|
|
// The bookmark route is an alias of the star route.
|
|
|
path := fmt.Sprintf("/v1/entries/%d/bookmark", entry.ID)
|
|
|
if status := requestStatus(t, regularTestUser, http.MethodPut, path); status != http.StatusNoContent {
|
|
|
- t.Fatalf(`Toggling the bookmark should return status %d, got %d`, http.StatusNoContent, status)
|
|
|
+ t.Errorf(`Unexpected status code when toggling the bookmark: got %d, want %d`, status, http.StatusNoContent)
|
|
|
}
|
|
|
|
|
|
entry, err = regularUserClient.Entry(entry.ID)
|
|
|
@@ -626,11 +626,11 @@ func TestToggleStarredEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entry.Starred {
|
|
|
- t.Fatalf(`The entry should no longer be starred`)
|
|
|
+ t.Errorf(`Unexpected starred flag: got %t, want %t`, entry.Starred, false)
|
|
|
}
|
|
|
|
|
|
if err := regularUserClient.ToggleStarred(nonexistentID); !errors.Is(err, miniflux.ErrNotFound) {
|
|
|
- t.Fatalf(`Expected Not Found when toggling the starred flag of a nonexistent entry: %v`, err)
|
|
|
+ t.Errorf(`Toggling the starred flag of a nonexistent entry: got error %v, want %v`, err, miniflux.ErrNotFound)
|
|
|
}
|
|
|
|
|
|
otherUserClient, _ := newRegularUser(t)
|
|
|
@@ -640,7 +640,7 @@ func TestToggleStarredEndpoint(t *testing.T) {
|
|
|
otherUserEntryID := servertest.FeedEntries(t, otherUserClient, otherFeedID)[0].ID
|
|
|
|
|
|
if err := regularUserClient.ToggleStarred(otherUserEntryID); !errors.Is(err, miniflux.ErrNotFound) {
|
|
|
- t.Fatalf(`Expected Not Found when toggling the starred flag of another user's entry: %v`, err)
|
|
|
+ t.Errorf(`Toggling the starred flag of an entry of another user: got error %v, want %v`, err, miniflux.ErrNotFound)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -665,7 +665,7 @@ func TestShareEntryEndpoint(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
if len(shareCode) < 8 {
|
|
|
- t.Fatal(`The entry should have a share code`)
|
|
|
+ t.Errorf(`Unexpected share code: got %q, want at least 8 characters`, shareCode)
|
|
|
}
|
|
|
|
|
|
existingShareCode, err := regularUserClient.ShareEntry(entryID)
|
|
|
@@ -673,7 +673,7 @@ func TestShareEntryEndpoint(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
if existingShareCode != shareCode {
|
|
|
- t.Fatalf(`Sharing an entry twice should return the same code, got %q and %q`, shareCode, existingShareCode)
|
|
|
+ t.Errorf(`Unexpected share code when sharing again: got %q, want %q`, existingShareCode, shareCode)
|
|
|
}
|
|
|
|
|
|
entryAfterShare, err := regularUserClient.Entry(entryID)
|
|
|
@@ -682,11 +682,11 @@ func TestShareEntryEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entryAfterShare.ShareCode != shareCode {
|
|
|
- t.Fatal(`The entry share code should match`)
|
|
|
+ t.Errorf(`Unexpected share code of the entry: got %q, want %q`, entryAfterShare.ShareCode, shareCode)
|
|
|
}
|
|
|
|
|
|
if !entryAfterShare.ChangedAt.After(entryBeforeShare.ChangedAt) {
|
|
|
- t.Fatalf(`Sharing should update the entry change date, got %v before and %v after`, entryBeforeShare.ChangedAt, entryAfterShare.ChangedAt)
|
|
|
+ t.Errorf(`Expected sharing to update the change date, got %v before and %v after`, entryBeforeShare.ChangedAt, entryAfterShare.ChangedAt)
|
|
|
}
|
|
|
|
|
|
if err := regularUserClient.UnshareEntry(entryID); err != nil {
|
|
|
@@ -699,18 +699,18 @@ func TestShareEntryEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if entryAfterUnshare.ShareCode != "" {
|
|
|
- t.Fatal(`The share code should be deleted`)
|
|
|
+ t.Errorf(`Unexpected share code after unsharing: got %q, want ""`, entryAfterUnshare.ShareCode)
|
|
|
}
|
|
|
|
|
|
if !entryAfterUnshare.ChangedAt.After(entryAfterShare.ChangedAt) {
|
|
|
- t.Fatalf(`Unsharing should update the entry change date, got %v before and %v after`, entryAfterShare.ChangedAt, entryAfterUnshare.ChangedAt)
|
|
|
+ t.Errorf(`Expected unsharing to update the change date, got %v before and %v after`, entryAfterShare.ChangedAt, entryAfterUnshare.ChangedAt)
|
|
|
}
|
|
|
|
|
|
if _, err = regularUserClient.ShareEntry(nonexistentID); !errors.Is(err, miniflux.ErrNotFound) {
|
|
|
- t.Fatalf(`Expected Not Found when sharing a nonexistent entry: %v`, err)
|
|
|
+ t.Errorf(`Sharing a nonexistent entry: got error %v, want %v`, err, miniflux.ErrNotFound)
|
|
|
}
|
|
|
if err = regularUserClient.UnshareEntry(nonexistentID); !errors.Is(err, miniflux.ErrNotFound) {
|
|
|
- t.Fatalf(`Expected Not Found when unsharing a nonexistent entry: %v`, err)
|
|
|
+ t.Errorf(`Unsharing a nonexistent entry: got error %v, want %v`, err, miniflux.ErrNotFound)
|
|
|
}
|
|
|
|
|
|
otherUserClient, _ := newRegularUser(t)
|
|
|
@@ -719,10 +719,10 @@ func TestShareEntryEndpoint(t *testing.T) {
|
|
|
|
|
|
otherUserEntryID := servertest.FeedEntries(t, otherUserClient, otherFeedID)[0].ID
|
|
|
if _, err = regularUserClient.ShareEntry(otherUserEntryID); !errors.Is(err, miniflux.ErrNotFound) {
|
|
|
- t.Fatalf(`Expected Not Found when sharing other user's entry: %v`, err)
|
|
|
+ t.Errorf(`Sharing an entry of another user: got error %v, want %v`, err, miniflux.ErrNotFound)
|
|
|
}
|
|
|
if err = regularUserClient.UnshareEntry(otherUserEntryID); !errors.Is(err, miniflux.ErrNotFound) {
|
|
|
- t.Fatalf(`Expected Not Found when unsharing other user's entry: %v`, err)
|
|
|
+ t.Errorf(`Unsharing an entry of another user: got error %v, want %v`, err, miniflux.ErrNotFound)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -738,7 +738,7 @@ func TestSaveEntryEndpoint(t *testing.T) {
|
|
|
entryID := servertest.FeedEntries(t, regularUserClient, feedID)[0].ID
|
|
|
|
|
|
if err := regularUserClient.SaveEntry(entryID); !errors.Is(err, miniflux.ErrBadRequest) {
|
|
|
- t.Fatalf(`Saving an entry should raise a bad request error because no integration is configured, got %v`, err)
|
|
|
+ t.Errorf(`Saving an entry without an integration: got error %v, want %v`, err, miniflux.ErrBadRequest)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -759,7 +759,7 @@ func TestFetchContentEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if !strings.Contains(content, servertest.ArticleText) {
|
|
|
- t.Fatalf(`The content should come from the original article page, got %q`, content)
|
|
|
+ t.Errorf(`Unexpected content: got %q, want it to contain %q`, content, servertest.ArticleText)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -809,7 +809,7 @@ func TestFlushHistoryEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if status := requestStatus(t, regularTestUser, http.MethodDelete, "/v1/flush-history"); status != http.StatusAccepted {
|
|
|
- t.Fatalf(`Flushing the history with DELETE should return status %d, got %d`, http.StatusAccepted, status)
|
|
|
+ t.Fatalf(`Unexpected status code when flushing the history with DELETE: got %d, want %d`, status, http.StatusAccepted)
|
|
|
}
|
|
|
waitForNoReadEntries()
|
|
|
}
|
|
|
@@ -839,7 +839,7 @@ func TestImportFeedEntryEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if firstID == 0 {
|
|
|
- t.Fatal("expected non-zero entry ID on first import")
|
|
|
+ t.Errorf(`Unexpected entry ID: got %d, want nonzero`, firstID)
|
|
|
}
|
|
|
|
|
|
// Importing the same external ID again returns the existing entry.
|
|
|
@@ -849,6 +849,6 @@ func TestImportFeedEntryEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
if secondID != firstID {
|
|
|
- t.Fatalf("expected same entry ID on re-import, got %d and %d", firstID, secondID)
|
|
|
+ t.Errorf(`Unexpected entry ID on re-import: got %d, want %d`, secondID, firstID)
|
|
|
}
|
|
|
}
|