From 09e73990a37fd50d852d6010018bfb97a5d363ef Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Sun, 29 Jan 2023 19:46:25 +0100 Subject: implement second part Signed-off-by: Benjamin Brahmer --- tests/updater/update.bats | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/updater/update.bats b/tests/updater/update.bats index 52f5d6d4f..04ab154ae 100644 --- a/tests/updater/update.bats +++ b/tests/updater/update.bats @@ -179,5 +179,31 @@ teardown() { assert_equal "${FIRST_UPDATE}" "" - ##TODO + # Generate feed "update" + php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 190 -s 80 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml + http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds/update userId=${user} feedId=$FEEDID + + # 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)') + + SECOND_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 "${SECOND_UPDATE}" "" + + # cleanup, purge items + http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/cleanup/after-update + + # Get all items, also read items + READ_ITEMS=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) + + assert_equal "${#READ_ITEMS[@]}" 200 } \ No newline at end of file -- cgit v1.2.3