From c2ee34baa53d24865fa2df3ebf9c6021201e5974 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Wed, 16 Mar 2022 20:44:34 +0100 Subject: create feed inside of folder Signed-off-by: Benjamin Brahmer --- tests/api/feeds.bats | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/api/feeds.bats b/tests/api/feeds.bats index 9b175df81..26bdbdbd8 100644 --- a/tests/api/feeds.bats +++ b/tests/api/feeds.bats @@ -9,10 +9,17 @@ setup() { TESTSUITE="Feeds" teardown() { + # delete all feeds ID=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/feeds | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ') for i in $ID; do http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/feeds/$i done + + # delete all folders + ID=$(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/folders | grep -Po '"id":\K([0-9]+)' | tr '\n' ' ') + for i in $ID; do + http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/folders/$i + done } @test "[$TESTSUITE] Read empty" { @@ -23,13 +30,25 @@ teardown() { } @test "[$TESTSUITE] Create new" { - # $() is needed in this case otherwise bats fails to fetch the output... - run $(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED | jq '.feeds | .[0].url') + # run is not working here. + output=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED | jq '.feeds | .[0].url') # self reference of feed is used here - assert_output --partial "https://nextcloud.com/blog/feed/" + assert_output '"https://nextcloud.com/blog/feed/"' } +@test "[$TESTSUITE] Create new inside folder" { + # create folder and store id + ID=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/folders name=news-${BATS_SUITE_TEST_NUMBER} | grep -Po '"id":\K([0-9]+)') + + # run is not working here. + output=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED folderId=$ID | jq '.feeds | .[0].folderId') + + # self reference of feed is used here + assert_output "$ID" +} + + @test "[$TESTSUITE] Delete one" { ID=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED | jq '.feeds | .[0].id') -- cgit v1.2.3