From fe1c42ce73b5c5ac3d499dad303a99dea240fcf4 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Fri, 18 Mar 2022 15:23:26 +0100 Subject: add test for reading 0 and 5 items Signed-off-by: Benjamin Brahmer --- tests/api/items.bats | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/api/items.bats diff --git a/tests/api/items.bats b/tests/api/items.bats new file mode 100644 index 000000000..cbb7a3960 --- /dev/null +++ b/tests/api/items.bats @@ -0,0 +1,43 @@ +#!/usr/bin/env bats + +setup() { + load "../test_helper/bats-support/load" + load "../test_helper/bats-assert/load" + load "helpers/settings" + + if test -f "tests/api/helpers/settings-override.bash"; then + load "helpers/settings-override" + fi +} + +TESTSUITE="Items" + +teardown() { + # delete all feeds + FEED_IDS=($(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/feeds | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) + for i in $FEED_IDS; do + http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/feeds/$i + done + + # delete all folders + FOLDER_IDS=($(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/folders | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) + for i in $FOLDER_IDS; do + http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/folders/$i + done +} + +@test "[$TESTSUITE] Read empty" { + run http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/items + + assert_output --partial "\"items\":[]" +} + +@test "[$TESTSUITE] Read 5" { + http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED + + ID_LIST=($(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/items batchSize=5 | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ')) + + output=${#ID_LIST[@]} + + assert_output --partial "5" +} \ No newline at end of file -- cgit v1.2.3