From c2f42f8c1137ae4b11ad23d5279c8000a0a5cfe4 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Fri, 2 Dec 2022 06:43:52 +0100 Subject: add first half of next test Signed-off-by: Benjamin Brahmer --- tests/updater/update.bats | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/updater/update.bats b/tests/updater/update.bats index 85129e232..e9820eb92 100644 --- a/tests/updater/update.bats +++ b/tests/updater/update.bats @@ -119,6 +119,8 @@ teardown() { assert_equal $STATUS_CODE 200 # check if amount is as expected assert_equal "${#ID_LIST2[@]}" 200 + + # unread items should be empty assert_output "" } @@ -152,4 +154,30 @@ teardown() { # check if amount is as expected assert_equal "${#ID_LIST2[@]}" 210 assert_output "" +} + +@test "[$TESTSUITE] Test Update and pruge with feed item>200; items<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 + + FIRST_UPDATE="$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items getRead=false | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')" + + assert_equal "${FIRST_UPDATE}" "" + + ##TODO } \ No newline at end of file -- cgit v1.2.3