From 3a7ed9e58ba7244d5cd1d82bcab1a47e49d7bbb9 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Thu, 10 Mar 2022 22:25:21 +0100 Subject: add first test add bats-assert and support as submodule test with all db types Signed-off-by: Benjamin Brahmer --- .github/workflows/api-integration-tests.yml | 12 ++++++------ .gitmodules | 6 ++++++ tests/api/folders.bats | 16 ++++++++++++++++ tests/api/helpers/settings.bash | 4 ++++ tests/test_helper/bats-assert | 1 + tests/test_helper/bats-support | 1 + 6 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 .gitmodules create mode 100644 tests/api/folders.bats create mode 100644 tests/api/helpers/settings.bash create mode 160000 tests/test_helper/bats-assert create mode 160000 tests/test_helper/bats-support diff --git a/.github/workflows/api-integration-tests.yml b/.github/workflows/api-integration-tests.yml index c1d7bb6f9..a10c2488c 100644 --- a/.github/workflows/api-integration-tests.yml +++ b/.github/workflows/api-integration-tests.yml @@ -48,6 +48,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + submodules: recursive - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -56,8 +58,8 @@ jobs: extensions: pdo_sqlite,pdo_mysql,pdo_pgsql,gd,zip coverage: none - - name: Setup BATS - uses: mig4/setup-bats@v1.2.0 + - name: Setup BATS & httpie + run: sudo apt-get install -y bats httpie ### MySQL specific setup - name: Setup mysql @@ -109,14 +111,12 @@ jobs: force: ${{ matrix.experimental }} - name: run api test - if: matrix.database == 'sqlite' working-directory: ../server run: | php -S localhost:8080 > /tmp/webserver.log & sleep 2 - - # Call folders api - curl -v -u admin:admin http://localhost:8080/index.php/apps/news/api/v1-2/folders + + bats apps/news/tests/api # Kill php server kill %1 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..d74af0778 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "tests/test_helper/bats-support"] + path = tests/test_helper/bats-support + url = https://github.com/bats-core/bats-support.git +[submodule "tests/test_helper/bats-assert"] + path = tests/test_helper/bats-assert + url = https://github.com/bats-core/bats-assert.git diff --git a/tests/api/folders.bats b/tests/api/folders.bats new file mode 100644 index 000000000..ef9c16b5a --- /dev/null +++ b/tests/api/folders.bats @@ -0,0 +1,16 @@ +#!/usr/bin/env bats + +setup() { + load "../test_helper/bats-support/load" + load "../test_helper/bats-assert/load" + load "helpers/settings" +} + +TESTSUITE="Folders" + + +@test "[$TESTSUITE] Create new" { + run http --ignore-stdin -b -a ${user}:${user} POST ${BASE_URLv1}/folders name=news-${BATS_SUITE_TEST_NUMBER} + + assert_output --partial "\"name\":\"news-${BATS_SUITE_TEST_NUMBER}\"," +} diff --git a/tests/api/helpers/settings.bash b/tests/api/helpers/settings.bash new file mode 100644 index 000000000..3b31fba4c --- /dev/null +++ b/tests/api/helpers/settings.bash @@ -0,0 +1,4 @@ +user=admin +NC_FEED="https://nextcloud.com/blog/static-feed/" +HEISE_FEED="https://www.heise.de/rss/heise-atom.xml" +BASE_URLv1="http://localhost:8080/index.php/apps/news/api/v1-2" \ No newline at end of file diff --git a/tests/test_helper/bats-assert b/tests/test_helper/bats-assert new file mode 160000 index 000000000..397c73521 --- /dev/null +++ b/tests/test_helper/bats-assert @@ -0,0 +1 @@ +Subproject commit 397c735212bf1a06cfdd0cb7806c5a6ea79582bf diff --git a/tests/test_helper/bats-support b/tests/test_helper/bats-support new file mode 160000 index 000000000..3c8fadc50 --- /dev/null +++ b/tests/test_helper/bats-support @@ -0,0 +1 @@ +Subproject commit 3c8fadc5097c9acfc96d836dced2bb598e48b009 -- cgit v1.2.3