summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Brahmer <info@b-brahmer.de>2022-03-10 22:25:21 +0100
committerBenjamin Brahmer <info@b-brahmer.de>2022-05-03 21:27:48 +0200
commit3a7ed9e58ba7244d5cd1d82bcab1a47e49d7bbb9 (patch)
tree7050a2f967df3e25c34ca8c24e4b2f2a48b39a43
parentd99bdf562d63f99a6d68a48a650233d50e834003 (diff)
add first test
add bats-assert and support as submodule test with all db types Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
-rw-r--r--.github/workflows/api-integration-tests.yml12
-rw-r--r--.gitmodules6
-rw-r--r--tests/api/folders.bats16
-rw-r--r--tests/api/helpers/settings.bash4
m---------tests/test_helper/bats-assert0
m---------tests/test_helper/bats-support0
6 files changed, 32 insertions, 6 deletions
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
+Subproject 397c735212bf1a06cfdd0cb7806c5a6ea79582b
diff --git a/tests/test_helper/bats-support b/tests/test_helper/bats-support
new file mode 160000
+Subproject 3c8fadc5097c9acfc96d836dced2bb598e48b00