Fix up tests

This commit is contained in:
Dimitry Ishenko
2025-02-02 20:36:28 -05:00
committed by Igor
parent 0ff69d3b62
commit 36735c00f0
8 changed files with 50 additions and 29 deletions

View File

@@ -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 $?
}
)}

View File

@@ -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
}
)}

View File

@@ -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
}
)}

View File

@@ -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
)}

View File

@@ -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 ]]
)}

View File

@@ -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
)}

View File

@@ -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" ]]
)}

View File

@@ -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).