Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to speedup the api testing by hosting the feeds locally #1874

Merged
merged 4 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/api-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ jobs:
working-directory: ../server
run: |
php -S localhost:8080 &> /tmp/webserver.log &
cd apps/news/tests/test_helper/feeds && php -S localhost:8090 &> /tmp/feedserver.log &

sleep 2

cd ${{ github.workspace }}/../server

bats apps/news/tests/api

# Kill php server
kill %1
kill %2

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
Expand All @@ -131,7 +136,14 @@ jobs:

- name: Functional tests
working-directory: ../server
run: bats apps/news/tests/command
run: |
cd apps/news/tests/test_helper/feeds && php -S localhost:8090 &> /tmp/feedserver.log &

sleep 2

cd ${{ github.workspace }}/../server

bats apps/news/tests/command

- name: Prep PHP tests
working-directory: ../server/apps/news
Expand Down
6 changes: 3 additions & 3 deletions tests/api/feeds.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ teardown() {
# delete all feeds
ID_LIST=($(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/feeds | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
for i in $ID_LIST; do
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/feeds/$i
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/feeds/$i > /dev/null
done

# delete all folders
ID_LIST=($(http --ignore-stdin -b -a ${user}:${user} GET ${BASE_URLv1}/folders | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
for i in $ID_LIST; do
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/folders/$i
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/folders/$i > /dev/null
done
}

Expand All @@ -37,7 +37,7 @@ teardown() {
# run is not working here.
output=$(http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/feeds url=$NC_FEED | jq '.feeds | .[0].url')

assert_output '"https://nextcloud.com/blog/static-feed/"'
assert_output '"http://localhost:8090/Nextcloud.rss"'
}

@test "[$TESTSUITE] Create new inside folder" {
Expand Down
4 changes: 2 additions & 2 deletions tests/api/folders.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ 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
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/feeds/$i > /dev/null
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
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/folders/$i > /dev/null
done
}

Expand Down
4 changes: 2 additions & 2 deletions tests/api/helpers/settings.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
user=admin
NC_FEED="https://nextcloud.com/blog/static-feed/"
HEISE_FEED="https://www.heise.de/rss/heise-atom.xml"
NC_FEED="http://localhost:8090/Nextcloud.rss"
HEISE_FEED="http://localhost:8090/heise.xml"
BASE_URLv1="http://localhost:8080/index.php/apps/news/api/v1-2"
4 changes: 2 additions & 2 deletions tests/api/items.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ 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
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/feeds/$i > /dev/null
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
http --ignore-stdin -b -a ${user}:${user} DELETE ${BASE_URLv1}/folders/$i > /dev/null
done
}

Expand Down
5 changes: 3 additions & 2 deletions tests/command/feeds.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ teardown() {
}

@test "[$TESTSUITE] Favicon" {
./occ news:feed:add "$user" "$NC_FEED" --title "Something-${BATS_SUITE_TEST_NUMBER}"
./occ news:feed:add "$user" "$HEISE_FEED" --title "Something-${BATS_SUITE_TEST_NUMBER}"

./occ news:feed:add "$user" "https://nextcloud.com/blog/static-feed/" --title "Something-${BATS_SUITE_TEST_NUMBER}"
./occ news:feed:add "$user" "https://www.heise.de/rss/heise-atom.xml" --title "Something-${BATS_SUITE_TEST_NUMBER}"

run ./occ news:feed:list "$user"
assert_success
Expand Down
6 changes: 3 additions & 3 deletions tests/command/helpers/settings.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
user=admin
NC_FEED="https://nextcloud.com/blog/static-feed/"
HEISE_FEED="https://www.heise.de/rss/heise-atom.xml"
NO_GUID_FEED="https://raw.githubusercontent.com/nextcloud/news/master/tests/command/feeds/no_guid_feed.xml"
NC_FEED="http://localhost:8090/Nextcloud.rss"
HEISE_FEED="http://localhost:8090/heise.xml"
NO_GUID_FEED="http://localhost:8090/no_guid_feed.xml"
Loading