From b808e2fe49914aba76d26316769c145c03456ffe Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Thu, 17 Mar 2022 19:32:22 +0100 Subject: test mark items of feed as read Signed-off-by: Benjamin Brahmer --- .github/workflows/api-integration-tests.yml | 2 +- tests/api/feeds.bats | 40 ++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/api-integration-tests.yml b/.github/workflows/api-integration-tests.yml index 2dabf30ae..117e7af49 100644 --- a/.github/workflows/api-integration-tests.yml +++ b/.github/workflows/api-integration-tests.yml @@ -110,7 +110,7 @@ jobs: check-code: false force: ${{ matrix.experimental }} - - name: run api test + - name: Run API tests working-directory: ../server run: | php -S localhost:8080 &> /tmp/webserver.log & diff --git a/tests/api/feeds.bats b/tests/api/feeds.bats index 83a47d5ab..78b0f2457 100644 --- a/tests/api/feeds.bats +++ b/tests/api/feeds.bats @@ -44,7 +44,7 @@ teardown() { # run is not working here. output=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED folderId=$ID | jq '.feeds | .[0].folderId') - # self reference of feed is used here + # check if ID matches assert_output "$ID" } @@ -69,7 +69,7 @@ teardown() { # run is not working here. output=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/feeds | jq '.feeds | .[0].folderId') - # self reference of feed is used here + # look for second folder id assert_output "$SECCOND_FOLDER_ID" } @@ -84,12 +84,12 @@ teardown() { # run is not working here. output=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/feeds | jq '.feeds | .[0].folderId') - # self reference of feed is used here + # new "folder" should be null assert_output null } @test "[$TESTSUITE] Rename feed" { - # create folder and store id + # create feed and store id FEEDID=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED | grep -Po '"id":\K([0-9]+)') # rename feed, returns nothing @@ -97,6 +97,34 @@ teardown() { # run is not working here. output=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/feeds | jq '.feeds | .[0].title') - # self reference of feed is used here + # Check if title matches assert_output '"Great Title"' -} \ No newline at end of file +} + +@test "[$TESTSUITE] Mark all items as read" { + # create feed and store id + FEEDID=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED | grep -Po '"id":\K([0-9]+)') + + ID=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/items id=$FEEDID | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ') + + # get biggest item ID + max=${ID[0]} + for n in "${ID[@]}" ; do + ((n > max)) && max=$n + done + + # mark all items of feed as read, returns nothing + http --ignore-stdin -b -a ${user}:${user} PUT ${BASE_URLv1}/feeds/$FEEDID/read newestItemId="$max" + + # collect unread status + unread=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/items id=$FEEDID | grep -Po '"unread":\K((true)|(false))' | tr '\n' ' ') + + for n in "${unread[@]}" ; do + if $n + then + echo "Item was not marked as read" + false + fi + done +} + -- cgit v1.2.3