mirror of
https://github.com/chylex/Nextcloud-News.git
synced 2025-04-10 13:15:42 +02:00
Actions: Integration tests using bats
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
This commit is contained in:
parent
59885c27f7
commit
bcdeb55fcb
@ -2,12 +2,20 @@ root = true
|
|||||||
|
|
||||||
[*]
|
[*]
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
[*.{js,php,html}]
|
[*.{js,php,html}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
|
|
||||||
|
[*.bats]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
charset = utf-8
|
||||||
|
|
||||||
[Makefile]
|
[Makefile]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
|
41
.github/workflows/api-integration-tests.yml
vendored
41
.github/workflows/api-integration-tests.yml
vendored
@ -55,6 +55,9 @@ jobs:
|
|||||||
extensions: pdo_sqlite,pdo_mysql,pdo_pgsql,gd,zip
|
extensions: pdo_sqlite,pdo_mysql,pdo_pgsql,gd,zip
|
||||||
coverage: none
|
coverage: none
|
||||||
|
|
||||||
|
- name: Setup BATS
|
||||||
|
uses: mig4/setup-bats@v1
|
||||||
|
|
||||||
### MySQL specific setup
|
### MySQL specific setup
|
||||||
- name: Setup mysql
|
- name: Setup mysql
|
||||||
if: matrix.database == 'mysql'
|
if: matrix.database == 'mysql'
|
||||||
@ -112,46 +115,14 @@ jobs:
|
|||||||
./occ migrations:migrate news
|
./occ migrations:migrate news
|
||||||
./occ maintenance:repair
|
./occ maintenance:repair
|
||||||
|
|
||||||
- name: Functional tests explore
|
- name: Functional tests
|
||||||
working-directory: ../server
|
working-directory: ../server
|
||||||
run: ./occ news:generate-explore --votes 100 "https://nextcloud.com/blog/feed/"
|
run: bats apps/news/tests/integration
|
||||||
|
|
||||||
- name: Functional tests folder
|
|
||||||
working-directory: ../server
|
|
||||||
run: |
|
|
||||||
./occ news:folder:add 'admin' 'Something'
|
|
||||||
./occ news:folder:list 'admin' | grep 'Something'
|
|
||||||
|
|
||||||
- name: Functional tests feed
|
|
||||||
working-directory: ../server
|
|
||||||
run: |
|
|
||||||
./occ news:feed:add 'admin' "https://nextcloud.com/blog/feed/"
|
|
||||||
./occ news:feed:add 'admin' "https://github.com/nextcloud/news/releases.atom"
|
|
||||||
./occ news:feed:list 'admin' | grep 'nextcloud\.com'
|
|
||||||
./occ news:feed:list 'admin' | grep -F '"faviconLink": "https:\/\/nextcloud.com\/media\/screenshot-150x150.png"'
|
|
||||||
|
|
||||||
- name: Functional tests items
|
|
||||||
working-directory: ../server
|
|
||||||
run: |
|
|
||||||
TAG=$(curl --silent "https://api.github.com/repos/nextcloud/news/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
|
||||||
./occ news:item:list-feed "admin" $(./occ news:feed:list 'admin' | grep 'github\.com' -1 | head -1 | grep -oE '[0-9]*') --limit 200 | grep "$TAG"
|
|
||||||
./occ news:item:list-folder "admin" --limit 200 | grep "$TAG"
|
|
||||||
./occ news:item:list "admin" --limit 200 | grep "$TAG"
|
|
||||||
|
|
||||||
- name: Functional tests opml
|
|
||||||
working-directory: ../server
|
|
||||||
run: ./occ news:opml:export 'admin' | grep 'nextcloud\.com'
|
|
||||||
|
|
||||||
- name: Functional tests cleanup
|
|
||||||
working-directory: ../server
|
|
||||||
run: |
|
|
||||||
./occ news:folder:delete 'admin' $(./occ news:folder:list 'admin' | grep 'Something' -1 | head -1 | grep -oE '[0-9]*')
|
|
||||||
./occ news:feed:delete 'admin' $(./occ news:feed:list 'admin' | grep 'nextcloud\.com' -1 | head -1 | grep -oE '[0-9]*')
|
|
||||||
./occ news:feed:delete 'admin' $(./occ news:feed:list 'admin' | grep 'github\.com' -1 | head -1 | grep -oE '[0-9]*')
|
|
||||||
|
|
||||||
- name: Prep PHP tests
|
- name: Prep PHP tests
|
||||||
working-directory: ../server/apps/news
|
working-directory: ../server/apps/news
|
||||||
run: make php-test-dependencies
|
run: make php-test-dependencies
|
||||||
|
|
||||||
- name: Feed tests
|
- name: Feed tests
|
||||||
working-directory: ../server/apps/news
|
working-directory: ../server/apps/news
|
||||||
run: make feed-test
|
run: make feed-test
|
||||||
|
@ -5,6 +5,7 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- Add BATS as integration tests
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -55,7 +55,9 @@ class FolderAdd extends Command
|
|||||||
$parent = intval($parent);
|
$parent = intval($parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->folderService->create($user, $name, $parent);
|
$folder = $this->folderService->create($user, $name, $parent);
|
||||||
|
|
||||||
|
$output->writeln('new folder: ' . $folder->getId());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
12
tests/integration/explore.bats
Normal file
12
tests/integration/explore.bats
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load "helpers/settings"
|
||||||
|
|
||||||
|
TESTSUITE="Explore"
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] Create new" {
|
||||||
|
curl --fail "$NC_FEED"
|
||||||
|
|
||||||
|
run ./occ news:generate-explore --votes 100 "$NC_FEED"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
71
tests/integration/feeds.bats
Normal file
71
tests/integration/feeds.bats
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load "helpers/settings"
|
||||||
|
|
||||||
|
TESTSUITE="Feeds"
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
ID=$(./occ news:feed:list 'admin' | grep "Something-${BATS_SUITE_TEST_NUMBER}" -2 | head -1 | grep -oE '[0-9]*')
|
||||||
|
if [ -n "$ID" ]; then
|
||||||
|
./occ news:feed:delete "$user" "$ID"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] Create new" {
|
||||||
|
run "./occ" news:feed:add "$user" "$NC_FEED"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
if ! echo "$output" | grep '"ID":'; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Feed ID not returned"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] List all" {
|
||||||
|
./occ news:feed:add "$user" "$NC_FEED" --title "Something-${BATS_SUITE_TEST_NUMBER}"
|
||||||
|
|
||||||
|
run ./occ news:feed:list "$user"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
if ! echo "$output" | grep "Something-${BATS_SUITE_TEST_NUMBER}"; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Feed not found in list"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! echo "$output" | grep -F '"faviconLink": "https:\/\/nextcloud.com\/media\/screenshot-150x150.png"'; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Favicon not found in list"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] List all items" {
|
||||||
|
./occ news:feed:add "$user" "https://github.com/nextcloud/news/releases.atom" --title "Something-${BATS_SUITE_TEST_NUMBER}"
|
||||||
|
|
||||||
|
TAG=$(curl --silent "https://api.github.com/repos/nextcloud/news/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||||
|
ID=$(./occ news:feed:list 'admin' | grep 'github\.com' -1 | head -1 | grep -oE '[0-9]*')
|
||||||
|
|
||||||
|
run ./occ news:item:list-feed "$user" "$ID" --limit 200
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
if ! echo "$output" | grep "$TAG"; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Release not found in list"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] Delete all" {
|
||||||
|
./occ news:feed:add "$user" "$NC_FEED" --title "Something-${BATS_SUITE_TEST_NUMBER}"
|
||||||
|
|
||||||
|
run ./occ news:feed:list "$user"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
echo "$output" | grep "Something-${BATS_SUITE_TEST_NUMBER}"
|
||||||
|
|
||||||
|
ID=$(./occ news:feed:list 'admin' | grep "Something-${BATS_SUITE_TEST_NUMBER}" -2 | head -1 | grep -oE '[0-9]*')
|
||||||
|
run ./occ news:feed:delete "$user" "$ID"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
49
tests/integration/folders.bats
Normal file
49
tests/integration/folders.bats
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load "helpers/settings"
|
||||||
|
|
||||||
|
TESTSUITE="Folders"
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
ID=$(./occ news:folder:list 'admin' | grep "Something-${BATS_SUITE_TEST_NUMBER}" -1 | head -1 | grep -oE '[0-9]*')
|
||||||
|
if [ -n "$ID" ]; then
|
||||||
|
./occ news:folder:delete "$user" "$ID"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] Create new" {
|
||||||
|
run ./occ news:folder:add "$user" "Something-${BATS_SUITE_TEST_NUMBER}"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
|
||||||
|
if echo "$output" | grep 'new folder'; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Folder ID not returned"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] List all" {
|
||||||
|
./occ news:folder:add "$user" "Something-${BATS_SUITE_TEST_NUMBER}"
|
||||||
|
|
||||||
|
run ./occ news:folder:list "$user"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
if echo "$output" | grep "Something-${BATS_SUITE_TEST_NUMBER}"; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Folder not found in list"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] Delete all" {
|
||||||
|
ID=$(./occ news:folder:add "$user" "Something-${BATS_SUITE_TEST_NUMBER}" | grep -oE '[0-9]*')
|
||||||
|
|
||||||
|
run ./occ news:folder:list "$user"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
echo "$output" | grep "Something-${BATS_SUITE_TEST_NUMBER}"
|
||||||
|
|
||||||
|
run ./occ news:folder:delete "$user" "$ID"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
2
tests/integration/helpers/settings.bash
Normal file
2
tests/integration/helpers/settings.bash
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
user=admin
|
||||||
|
NC_FEED="https://nextcloud.com/blog/static-feed/"
|
51
tests/integration/items.bats
Normal file
51
tests/integration/items.bats
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load "helpers/settings"
|
||||||
|
|
||||||
|
TESTSUITE="Items"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
./occ news:feed:add "$user" "https://github.com/nextcloud/news/releases.atom" --title "Something-${BATS_SUITE_TEST_NUMBER}"
|
||||||
|
|
||||||
|
TAG=$(curl --silent "https://api.github.com/repos/nextcloud/news/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||||
|
ID=$(./occ news:feed:list 'admin' | grep 'github\.com' -1 | head -1 | grep -oE '[0-9]*')
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
if [ -n "$ID" ]; then
|
||||||
|
./occ news:feed:delete "$user" "$ID"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] List all items in feed" {
|
||||||
|
run ./occ news:item:list-feed "$user" "$ID" --limit 200
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
if ! echo "$output" | grep "$TAG"; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Release not found in feed list"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] List all items in folder" {
|
||||||
|
run ./occ news:item:list-folder "$user" --limit 200
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
if ! echo "$output" | grep "$TAG"; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Release not found in folder list"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] List all items" {
|
||||||
|
run ./occ news:item:list "$user" --limit 200
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
if ! echo "$output" | grep "$TAG"; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Release not found in list"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
26
tests/integration/opml.bats
Normal file
26
tests/integration/opml.bats
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load "helpers/settings"
|
||||||
|
|
||||||
|
TESTSUITE="OPML"
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
ID=$(./occ news:feed:list 'admin' | grep "Something-${BATS_SUITE_TEST_NUMBER}" -1 | head -1 | grep -oE '[0-9]*')
|
||||||
|
if [ -n "$ID" ]; then
|
||||||
|
./occ news:feed:delete "$user" "$ID"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "[$TESTSUITE] Export" {
|
||||||
|
run ./occ news:feed:add "$user" "https://nextcloud.com/blog/static-feed/"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
run ./occ news:opml:export "$user"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
if ! echo "$output" | grep "https://nextcloud.com/"; then
|
||||||
|
ret_status=$?
|
||||||
|
echo "Feed not exported"
|
||||||
|
return $ret_status
|
||||||
|
fi
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user