mirror of
https://github.com/armbian/configng.git
synced 2026-01-06 10:37:41 -08:00
Fix up tests
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
ENABLED=true
|
||||
RELEASE="bookworm:noble"
|
||||
|
||||
function testcase {
|
||||
./bin/armbian-config --api module_portainer remove
|
||||
testcase() {(
|
||||
set -e
|
||||
./bin/armbian-config --api module_portainer install
|
||||
./bin/armbian-config --api module_portainer status
|
||||
echo $?
|
||||
}
|
||||
)}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
ENABLED=false
|
||||
|
||||
function testcase {
|
||||
testcase() {(
|
||||
set -e
|
||||
./bin/armbian-config --api module_mariadb install
|
||||
./bin/armbian-config --api module_mariadb status
|
||||
docker container ls -a
|
||||
}
|
||||
)}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
ENABLED=true
|
||||
RELEASE="bookworm"
|
||||
|
||||
function testcase {
|
||||
function testcase {(
|
||||
set -e
|
||||
./bin/armbian-config --api module_openhab install
|
||||
systemctl is-active --quiet openhab.service
|
||||
}
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
ENABLED=false
|
||||
RELEASE="bookworm"
|
||||
|
||||
function testcase {
|
||||
testcase() {(
|
||||
set -e
|
||||
./bin/armbian-config --api module_haos install
|
||||
}
|
||||
./bin/armbian-config --api module_haos status
|
||||
)}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
ENABLED=true
|
||||
RELEASE="bookworm:noble" # run on specific or leave empty to run on all
|
||||
|
||||
function testcase {
|
||||
./bin/armbian-config --api module_cockpit remove
|
||||
testcase() {(
|
||||
set -e
|
||||
./bin/armbian-config --api module_cockpit remove || true
|
||||
./bin/armbian-config --api module_cockpit install
|
||||
[ -f /usr/bin/cockpit-bridge ]
|
||||
}
|
||||
|
||||
[[ -f /usr/bin/cockpit-bridge ]]
|
||||
)}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
ENABLED=true
|
||||
RELEASE="bookworm:noble"
|
||||
|
||||
function testcase {
|
||||
./bin/armbian-config --api module_uptimekuma remove
|
||||
testcase() {(
|
||||
set -e
|
||||
./bin/armbian-config --api module_uptimekuma remove || true
|
||||
./bin/armbian-config --api module_uptimekuma install
|
||||
./bin/armbian-config --api module_uptimekuma status
|
||||
./bin/armbian-config --api module_uptimekuma remove
|
||||
./bin/armbian-config --api module_uptimekuma status
|
||||
}
|
||||
! ./bin/armbian-config --api module_uptimekuma status
|
||||
)}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
ENABLED=true
|
||||
RELEASE="bookworm:noble"
|
||||
|
||||
function testcase {
|
||||
testcase() {(
|
||||
set -e
|
||||
./bin/armbian-config --api module_navidrome remove
|
||||
./bin/armbian-config --api module_navidrome install
|
||||
container=$(docker container ls -a | mawk '/navidrome?( |$)/{print $1}')
|
||||
if [[ -z "${container}" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
[[ -n "$container" ]]
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Unit tests
|
||||
|
||||
If function testcase returns 0, test is succesful. Put the code there.
|
||||
If the function `testcase()` returns 0, the test is succesful. Put the code there.
|
||||
|
||||
- name of the the file is function ID.conf
|
||||
- ENABLED=false|true
|
||||
@@ -8,12 +8,29 @@ If function testcase returns 0, test is succesful. Put the code there.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
```sh
|
||||
ENABLED=true
|
||||
RELEASE="bookworm:noble"
|
||||
|
||||
function testcase {
|
||||
./bin/armbian-config --api module_cockpit install
|
||||
[ -f /usr/bin/cockpit-bridge ]
|
||||
testcase() {
|
||||
./bin/armbian-config --api module_cockpit install
|
||||
[ -f /usr/bin/cockpit-bridge ]
|
||||
}
|
||||
```
|
||||
|
||||
If you have multiple test conditions inside `testcase()` and you want the test
|
||||
to exit on the first failed statement, you can use the following technique:
|
||||
|
||||
```sh
|
||||
testcase() {(
|
||||
set -e
|
||||
./bin/armbian-config --api pkg_install neovim
|
||||
./bin/armbian-config --api pkg_installed neovim
|
||||
./bin/armbian-config --api pkg_remove neovim
|
||||
! ./bin/armbian-config --api pkg_installed neovim
|
||||
)}
|
||||
```
|
||||
|
||||
Note the additional pair of `()` and the `set -e` command inside function body.
|
||||
These will cause test conditions to run inside a subshell with the -e option
|
||||
enabled (exit immediately if a pipeline returns non-zero status).
|
||||
|
||||
Reference in New Issue
Block a user