summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Brahmer <info@b-brahmer.de>2022-03-18 15:23:26 +0100
committerBenjamin Brahmer <info@b-brahmer.de>2022-05-03 21:27:48 +0200
commitfe1c42ce73b5c5ac3d499dad303a99dea240fcf4 (patch)
tree1787b8e62bd9d63a812390e758f233edc601951b
parent6e64318df5e2f81bda25977e11e20838df424588 (diff)
add test for reading 0 and 5 items
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
-rw-r--r--tests/api/items.bats43
1 files changed, 43 insertions, 0 deletions
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