Skip to content

Commit

Permalink
test: added test tags
Browse files Browse the repository at this point in the history
  • Loading branch information
sidey79 committed Apr 1, 2024
1 parent b4e931e commit 16f7fac
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/tests/bats/aptInstall.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ teardown() {
DEBIAN_FRONTEND=noninteractive apt-get remove dummydroid -y && apt-get autoremove -y # cleanup
}


# bats test_tags=integrationTest
@test "check aptInstall() new package" {
bats_require_minimum_version 1.5.0

Expand All @@ -44,6 +44,7 @@ teardown() {

}

# bats test_tags=integrationTest
@test "check aptInstall() already installed package" {
bats_require_minimum_version 1.5.0

Expand All @@ -55,6 +56,7 @@ teardown() {
assert_output --partial "test message2"
}

# bats test_tags=integrationTest
@test "check aptInstall() twice executed" {
bats_require_minimum_version 1.5.0

Expand Down
11 changes: 8 additions & 3 deletions src/tests/bats/entry.bats
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,20 @@ teardown() {
}



# bats test_tags=unitTest
@test "printf info tests" {
run printfInfo 'test output'
assert_output 'INFO: test output'
}

# bats test_tags=unitTest
@test "printf debug tests" {
declare -i gEnableDebug=1
run printfDebug 'test output'
assert_output 'DEBUG: bats_merge_stdout_and_stderr: test output'
}

# bats test_tags=unitTest
@test "check prependFhemDirPath()" {

run bash -c 'OUT=$(prependFhemDirPath "") ; echo $OUT'
Expand All @@ -67,7 +69,7 @@ teardown() {

}


# bats test_tags=unitTest
@test "check fhemUpdateInstall()" {
export FHEM_DIR=${BATS_TEST_TMPDIR}"/fhemUpdateInstall"
mkdir -p ${FHEM_DIR}/FHEM
Expand All @@ -80,6 +82,7 @@ teardown() {
#rm -r ${FHEM_DIR}
}

# bats test_tags=unitTest
@test "ceck tailFileToConsoleStop() Logfile monitoring" {
# mock some functions
LOGFILE="fhem-%Y-%m-%d.log"
Expand All @@ -95,6 +98,7 @@ teardown() {
echo $gCurrentTailPid | assert_output ""
}

# bats test_tags=unitTest
@test "ceck tailFileToConsoleStart() Logfile monitoring" {
# mock some functions
function getFhemPidNum() {
Expand All @@ -121,7 +125,7 @@ teardown() {
refute_output "hello"
}


# bats test_tags=integrationTest
@test "Setup clean install FHEM" {

run fhemCleanInstall
Expand All @@ -134,6 +138,7 @@ teardown() {

}

# bats test_tags=unitTest
@test "verify is_absolutePath" {
bats_require_minimum_version 1.5.0

Expand Down
5 changes: 3 additions & 2 deletions src/tests/bats/health-check.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ teardown() {
pkill perl || true
}


# bats test_tags=unitTest
@test "healthcheck without url file" {
bats_require_minimum_version 1.5.0

run -1 /health-check.sh
assert_output --partial "Cannot read url file"
}

# bats test_tags=unitTest
@test "healthcheck without running fhem" {
bats_require_minimum_version 1.5.0

Expand All @@ -45,7 +46,7 @@ teardown() {
rm -r /tmp/health-check.urls
}

# bats test_tags=unitTest
# bats test_tags=integrationTest
@test "healthcheck with running fhem" {
bats_require_minimum_version 1.5.0

Expand Down
8 changes: 6 additions & 2 deletions src/tests/bats/pidfile.bats
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,22 @@ teardown() {
}



# bats test_tags=unitTest
@test "verify setGlobal_PIDFILE default pidfile" {

run bash -c 'unset PIDFILE; setGlobal_PIDFILE ; echo $PIDFILE'
assert_output "/opt/fhem/log/fhem.pid"
}

# bats test_tags=unitTest
@test "verify setGlobal_PIDFILE absolut pidfile" {
export PIDFILE="/run/lock/fhem.pid"

run bash -c 'setGlobal_PIDFILE ; echo $PIDFILE'
assert_output "/run/lock/fhem.pid"
}

# bats test_tags=unitTest
@test "verify setGlobal_PIDFILE relative pidfile" {
export PIDFILE="./run/fhem.pid"

Expand All @@ -73,7 +75,7 @@ teardown() {
}


### cd /opt/fhem && timeout 33 bats /code/pidfile.bats -f fhem.cfg; cat /tmp/log; ps aux ;
# bats test_tags=integrationTest
@test "integration: absoulte pidfile set in fhem.cfg" {
# Container setup
run bash -c 'cd $FHEM_DIR && initialContainerSetup > ${LOG_FILE}'
Expand All @@ -97,6 +99,7 @@ teardown() {
assert_file_contains ${LOG_FILE} 'From the FHEM_GLOBALATTR environment: attr global pidfilename /run/lock/fhem.pid' grep
}

# bats test_tags=integrationTest
@test "integration: absoulte pidfile set in environment" {
# Container setup
run bash -c 'cd $FHEM_DIR && initialContainerSetup > ${LOG_FILE}'
Expand All @@ -121,6 +124,7 @@ teardown() {
kill $ENTRY_PID # fail it the process already finished due to error!
}

# bats test_tags=integrationTest
@test "integration: default pidfile" {
# Container setup
run bash -c 'cd $FHEM_DIR && initialContainerSetup > ${LOG_FILE}'
Expand Down

0 comments on commit 16f7fac

Please sign in to comment.