From 2a0e75e7478cb6101d3f562fb619597b34574a3f Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Fri, 18 Mar 2022 20:44:01 +0100 Subject: test check updated items, not final Signed-off-by: Benjamin Brahmer --- tests/api/items.bats | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/api/items.bats b/tests/api/items.bats index cbb7a3960..f1ca82987 100644 --- a/tests/api/items.bats +++ b/tests/api/items.bats @@ -40,4 +40,28 @@ teardown() { output=${#ID_LIST[@]} assert_output --partial "5" +} + +# TODO GET /items has more options that could be tested. + +@test "[$TESTSUITE] Check updated" { + FEEDID=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED | 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 + + SYNC_TIME=$(date +%s) + + # mark all items of feed as read, returns nothing (other client marks items as read) + STATUS_CODE=$(http --ignore-stdin -hdo /tmp/body -a ${user}:${user} PUT ${BASE_URLv1}/feeds/$FEEDID/read newestItemId="$max" 2>&1| grep HTTP/) + + # client 2 checks for updates since last sync + UPDATED_ITEMS=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/items/updated id=$FEEDID lastModified=$SYNC_TIME | tr -d '[:space:]') + + echo $UPDATED_ITEMS + false } \ No newline at end of file -- cgit v1.2.3