@@ -2381,7 +2381,6 @@ func TestGetGlobalEntriesEndpoint(t *testing.T) {
23812381 }
23822382
23832383 feedIDEntry , err := regularUserClient .Feed (feedID )
2384-
23852384 if err != nil {
23862385 t .Fatal (err )
23872386 }
@@ -2413,6 +2412,64 @@ func TestGetGlobalEntriesEndpoint(t *testing.T) {
24132412 }
24142413}
24152414
2415+ func TestCannotGetRemovedEntries (t * testing.T ) {
2416+ testConfig := newIntegrationTestConfig ()
2417+ if ! testConfig .isConfigured () {
2418+ t .Skip (skipIntegrationTestsMessage )
2419+ }
2420+
2421+ adminClient := miniflux .NewClient (testConfig .testBaseURL , testConfig .testAdminUsername , testConfig .testAdminPassword )
2422+
2423+ regularTestUser , err := adminClient .CreateUser (testConfig .genRandomUsername (), testConfig .testRegularPassword , false )
2424+ if err != nil {
2425+ t .Fatal (err )
2426+ }
2427+ defer adminClient .DeleteUser (regularTestUser .ID )
2428+
2429+ regularUserClient := miniflux .NewClient (testConfig .testBaseURL , regularTestUser .Username , testConfig .testRegularPassword )
2430+
2431+ feedID , err := regularUserClient .CreateFeed (& miniflux.FeedCreationRequest {
2432+ FeedURL : testConfig .testFeedURL ,
2433+ })
2434+ if err != nil {
2435+ t .Fatal (err )
2436+ }
2437+
2438+ feedEntries , err := regularUserClient .Entries (& miniflux.Filter {FeedID : feedID })
2439+ if err != nil {
2440+ t .Fatal (err )
2441+ }
2442+
2443+ if feedEntries .Total == 0 {
2444+ t .Fatalf (`Expected at least one entry, got none` )
2445+ }
2446+
2447+ if err := regularUserClient .UpdateEntries ([]int64 {feedEntries .Entries [0 ].ID }, miniflux .EntryStatusRemoved ); err != nil {
2448+ t .Fatal (err )
2449+ }
2450+
2451+ if _ , err := regularUserClient .Entry (feedEntries .Entries [0 ].ID ); err != miniflux .ErrNotFound {
2452+ t .Fatalf (`Expected entry to be not found, got %v` , err )
2453+ }
2454+
2455+ if _ , err := regularUserClient .FeedEntry (feedID , feedEntries .Entries [0 ].ID ); err != miniflux .ErrNotFound {
2456+ t .Fatalf (`Expected entry to be not found, got %v` , err )
2457+ }
2458+
2459+ if _ , err := regularUserClient .CategoryEntry (feedEntries .Entries [0 ].Feed .Category .ID , feedEntries .Entries [0 ].ID ); err != miniflux .ErrNotFound {
2460+ t .Fatalf (`Expected entry to be not found, got %v` , err )
2461+ }
2462+
2463+ updatedFeedEntries , err := regularUserClient .Entries (& miniflux.Filter {FeedID : feedID })
2464+ if err != nil {
2465+ t .Fatal (err )
2466+ }
2467+
2468+ if updatedFeedEntries .Total != feedEntries .Total - 1 {
2469+ t .Fatalf (`Expected %d entries, got %d` , feedEntries .Total - 1 , updatedFeedEntries .Total )
2470+ }
2471+ }
2472+
24162473func TestUpdateEnclosureEndpoint (t * testing.T ) {
24172474 testConfig := newIntegrationTestConfig ()
24182475 if ! testConfig .isConfigured () {
@@ -2631,64 +2688,6 @@ func TestUpdateEntryStatusEndpoint(t *testing.T) {
26312688 }
26322689}
26332690
2634- func TestUpdateEntryRemovedStatusEndpoint (t * testing.T ) {
2635- testConfig := newIntegrationTestConfig ()
2636- if ! testConfig .isConfigured () {
2637- t .Skip (skipIntegrationTestsMessage )
2638- }
2639-
2640- adminClient := miniflux .NewClient (testConfig .testBaseURL , testConfig .testAdminUsername , testConfig .testAdminPassword )
2641-
2642- regularTestUser , err := adminClient .CreateUser (testConfig .genRandomUsername (), testConfig .testRegularPassword , false )
2643- if err != nil {
2644- t .Fatal (err )
2645- }
2646- defer adminClient .DeleteUser (regularTestUser .ID )
2647-
2648- regularUserClient := miniflux .NewClient (testConfig .testBaseURL , regularTestUser .Username , testConfig .testRegularPassword )
2649-
2650- feedID , err := regularUserClient .CreateFeed (& miniflux.FeedCreationRequest {
2651- FeedURL : testConfig .testFeedURL ,
2652- })
2653- if err != nil {
2654- t .Fatal (err )
2655- }
2656-
2657- result , err := regularUserClient .FeedEntries (feedID , nil )
2658- if err != nil {
2659- t .Fatalf (`Failed to get entries: %v` , err )
2660- }
2661-
2662- // First we set the entry as "removed"
2663- if err := regularUserClient .UpdateEntries ([]int64 {result .Entries [0 ].ID }, miniflux .EntryStatusRemoved ); err != nil {
2664- t .Fatal (err )
2665- }
2666-
2667- entry , err := regularUserClient .Entry (result .Entries [0 ].ID )
2668- if err != nil {
2669- t .Fatal (err )
2670- }
2671-
2672- if entry .Status != miniflux .EntryStatusRemoved {
2673- t .Fatalf (`Invalid status, got %q instead of %q` , entry .Status , miniflux .EntryStatusRemoved )
2674- }
2675-
2676- // Then we try to set it to "unread"
2677- if err := regularUserClient .UpdateEntries ([]int64 {result .Entries [0 ].ID }, miniflux .EntryStatusUnread ); err != nil {
2678- t .Fatal (err )
2679- }
2680-
2681- entry , err = regularUserClient .Entry (result .Entries [0 ].ID )
2682- if err != nil {
2683- t .Fatal (err )
2684- }
2685-
2686- // It should stay set to "removed"
2687- if entry .Status != miniflux .EntryStatusRemoved {
2688- t .Fatalf (`Modified immutable status: got %q instead of %q` , entry .Status , miniflux .EntryStatusRemoved )
2689- }
2690- }
2691-
26922691func TestUpdateEntryEndpoint (t * testing.T ) {
26932692 testConfig := newIntegrationTestConfig ()
26942693 if ! testConfig .isConfigured () {
@@ -2932,13 +2931,4 @@ func TestFlushHistoryEndpoint(t *testing.T) {
29322931 if readEntries .Total != 0 {
29332932 t .Fatalf (`Invalid total, got %d` , readEntries .Total )
29342933 }
2935-
2936- removedEntries , err := regularUserClient .Entries (& miniflux.Filter {Status : miniflux .EntryStatusRemoved })
2937- if err != nil {
2938- t .Fatal (err )
2939- }
2940-
2941- if removedEntries .Total != 2 {
2942- t .Fatalf (`Invalid total, got %d` , removedEntries .Total )
2943- }
29442934}
0 commit comments