From 3bee89025236aa509da45350073f41e208d12ee9 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Sun, 29 Dec 2024 15:51:32 +0100 Subject: [PATCH] fixup Signed-off-by: Benjamin Brahmer --- tests/updater/update.bats | 54 ++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/tests/updater/update.bats b/tests/updater/update.bats index 33269664c..5c17d97d0 100644 --- a/tests/updater/update.bats +++ b/tests/updater/update.bats @@ -46,9 +46,9 @@ teardown() { @test "[$TESTSUITE] Test simple update" { # Create Feed FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$TEST_FEED | grep -Po '"id":\K([0-9]+)') - + sleep 2 - + # Get Items ID_LIST1=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) # Trigger Update @@ -65,7 +65,7 @@ teardown() { @test "[$TESTSUITE] Test if nextUpdateTime is updated" { # Create Feed FEED=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$TEST_FEED) - + UpdateTime1=$(echo $FEED | jq '.feeds | .[0].nextUpdateTime') FEEDID=$(echo $FEED | jq '.feeds | .[0].id') @@ -87,7 +87,7 @@ teardown() { sleep 2 UpdateTime2=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds | jq '.feeds | .[0].nextUpdateTime') - + # Assert that UpdateTime2 is within the expected range run bash -c "[[ $UpdateTime2 -ge $expected_time_min && $UpdateTime2 -le $expected_time_max ]]" assert_success @@ -100,9 +100,9 @@ teardown() { # Create Feed FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$TEST_FEED | grep -Po '"id":\K([0-9]+)') - + sleep 2 - + # Get Items ID_LIST1=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) @@ -110,7 +110,7 @@ teardown() { # Trigger Update http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds/update userId=${user} feedId=$FEEDID - + sleep 2 # Get Items again @@ -127,9 +127,9 @@ teardown() { #@test "[$TESTSUITE] Test feed with 'outdated' items https://github.com/nextcloud/news/issues/2236 " { # # Create Feed, for the first fetch a timestamp today -1 year is used. # FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$TEST_FEED | grep -Po '"id":\K([0-9]+)') -# +# # sleep 2 -# +# # # Get Items # ID_LIST1=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) # @@ -138,7 +138,7 @@ teardown() { # # # Trigger Update # http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds/update userId=${user} feedId=$FEEDID -# +# # sleep 2 # # # Get Items again @@ -152,6 +152,9 @@ teardown() { #} @test "[$TESTSUITE] Test purge with small feed" { + # Disable useNextUpdateTime + ./occ config:app:set news useNextUpdateTime --value=false + # Generate Feed with 210 items. php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 50 -s 0 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml # Create Feed @@ -191,10 +194,10 @@ teardown() { 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 @@ -213,13 +216,16 @@ teardown() { } @test "[$TESTSUITE] Test purge with more items than default limit 200" { + # Disable useNextUpdateTime + ./occ config:app:set news useNextUpdateTime --value=false + # 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]+)') - + sleep 2 - + # Get Items ID_LIST=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) @@ -228,10 +234,10 @@ teardown() { 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 @@ -248,6 +254,9 @@ teardown() { } @test "[$TESTSUITE] Test Update and pruge with feed item>200; items<200" { + # Disable useNextUpdateTime + ./occ config:app:set news useNextUpdateTime --value=false + # 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 @@ -260,7 +269,7 @@ teardown() { 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 @@ -282,7 +291,7 @@ teardown() { 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)') @@ -301,11 +310,14 @@ teardown() { } @test "[$TESTSUITE] Test purge with two feeds with different item count limit" { + # Disable useNextUpdateTime + ./occ config:app:set news useNextUpdateTime --value=false + # Generate Feed with 260 items. php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 260 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/feed1.xml # 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/feed2.xml - + # Create Feeds FEED1ID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$FEED1 | grep -Po '"id":\K([0-9]+)') FEED2ID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$FEED2 | grep -Po '"id":\K([0-9]+)') @@ -317,11 +329,11 @@ teardown() { for n in "${ID_LIST[@]}" ; do ((n > max)) && max=$n done - + # mark all items of both feeds as read, returns nothing STATUS_CODE1=$(http --ignore-stdin -hdo /tmp/body -a ${user}:${APP_PASSWORD} PUT ${BASE_URLv1}/feeds/$FEED1ID/read newestItemId="$max" 2>&1| grep -Po '(?<=HTTP\/1\.1 )[0-9]{3}(?= OK)') STATUS_CODE2=$(http --ignore-stdin -hdo /tmp/body -a ${user}:${APP_PASSWORD} PUT ${BASE_URLv1}/feeds/$FEED2ID/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