diff options
author | Benjamin Brahmer <info@b-brahmer.de> | 2022-10-27 16:55:45 +0200 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2023-01-29 19:25:35 +0100 |
commit | 971c810a13d25b013c7345cd938d5929a943ddb3 (patch) | |
tree | aea81c7efe9d0d1f690f7bea2c18e837cd2136bc | |
parent | 6b14559e6493eaaf9df5d08fb8aa4c0b208ffd04 (diff) |
add another test
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
-rw-r--r-- | tests/updater/update.bats | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/tests/updater/update.bats b/tests/updater/update.bats index 9b3504bdd..1dd09b553 100644 --- a/tests/updater/update.bats +++ b/tests/updater/update.bats @@ -17,7 +17,7 @@ teardown_file(){ setup() { load "../test_helper/bats-support/load" load "../test_helper/bats-assert/load" - php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 50 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml + php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 10 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml } TESTSUITE="Update" @@ -61,7 +61,7 @@ teardown() { # Get Items ID_LIST1=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) - php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 60 -s 41 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml + php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 15 -s 9 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml # Trigger Update http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds/update userId=${user} feedId=$FEEDID @@ -73,4 +73,36 @@ teardown() { # Check that they are not equal but that they match partially. assert_not_equal "${ID_LIST1[*]}" "${ID_LIST2[*]}" assert_output --partial "${ID_LIST1[*]}" +} + +@test "[$TESTSUITE] Test purge with more items than default limit 200" { + # Generate Feed with 210 items. + php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 210 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml + # Create Feed + FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$TEST_FEED | grep -Po '"id":\K([0-9]+)') + # Get Items + ID_LIST=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | 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}:${APP_PASSWORD} PUT ${BASE_URLv1}/feeds/$FEEDID/read newestItemId="$max" 2>&1| grep -Po '(?<=HTTP\/1\.1 )[0-9]{3}(?= OK)') + + # cleanup, purge items + http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/cleanup/after-update + + # Get unread Items, should be empty + output="$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items getRead=false | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')" + + # Get all items, also read items + ID_LIST2=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) + + assert_equal $STATUS_CODE 200 + # check if amount is as expected + assert_equal "${#ID_LIST2[@]}" 210 + assert_output "" }
\ No newline at end of file |