summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Brahmer <info@b-brahmer.de>2022-03-18 10:18:23 +0100
committerBenjamin Brahmer <info@b-brahmer.de>2022-05-03 21:27:48 +0200
commitf306075b3294929a8f7b0a74886dd9fd6a7fad1e (patch)
tree77c107434155f4ad4726358b7985f5d4c04928ad
parent0e3481a454d3fb0d28403e86434e3aa02cd45fb5 (diff)
test mark items of folder as read
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
-rw-r--r--tests/api/folders.bats43
1 files changed, 40 insertions, 3 deletions
diff --git a/tests/api/folders.bats b/tests/api/folders.bats
index 4dfe9129a..75d8339bb 100644
--- a/tests/api/folders.bats
+++ b/tests/api/folders.bats
@@ -9,8 +9,15 @@ setup() {
TESTSUITE="Folders"
teardown() {
- ID=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/folders | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')
- for i in $ID; do
+ # delete all feeds
+ FEED_IDS=($(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/feeds | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
+ for i in $FEED_IDS; do
+ http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/feeds/$i
+ done
+
+ # delete all folders
+ FOLDER_IDS=($(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/folders | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
+ for i in $FOLDER_IDS; do
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/folders/$i
done
}
@@ -44,4 +51,34 @@ teardown() {
run http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/folders
assert_output --partial "\"name\":\"rename-${BATS_SUITE_TEST_NUMBER}\","
-} \ No newline at end of file
+}
+
+@test "[$TESTSUITE] Mark all items as read" {
+ # create folder and feed in folder
+ FOLDER_ID=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/folders name=news-${BATS_SUITE_TEST_NUMBER} | grep -Po '"id":\K([0-9]+)')
+ FEED_ID=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED folderId=$FOLDER_ID | grep -Po '"id":\K([0-9]+)')
+
+ ID_LIST=($(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_LIST[0]}
+ for n in "${ID_LIST[@]}" ; do
+ ((n > max)) && max=$n
+ done
+
+ # mark all items of feed as read, returns nothing
+ STATUS_CODE=$(http --ignore-stdin -hdo /tmp/body -a ${user}:${user} PUT ${BASE_URLv1}/folders/$FOLDER_ID/read newestItemId="$max" 2>&1| grep HTTP/)
+
+ # 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"
+ echo $STATUS_CODE
+ false
+ fi
+ done
+}
+