Skip to content

Commit

Permalink
Add bast-assert
Browse files Browse the repository at this point in the history
Signed-off-by: yubiuser <[email protected]>
  • Loading branch information
yubiuser committed Sep 18, 2024
1 parent 06ffb18 commit d345655
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ ENV BUILD_OPTS=${BUILD_OPTS}
RUN apk add --no-cache ncurses
ENV TERM=xterm

# Add bats-support for testing
# Add bats-support and bats-assert for testing
RUN git clone --depth=1 --quiet https://github.com/bats-core/bats-support test/libs/bats-support > /dev/null
RUN git clone --depth=1 --quiet https://github.com/bats-core/bats-assert test/libs/bats-assert > /dev/null

# Build FTL
# Remove possible old build files
Expand Down
2 changes: 1 addition & 1 deletion test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ echo -n "Contained dnsmasq version (DNS): "
dig TXT CHAOS version.bind @127.0.0.1 +short

# Run tests
$BATS -p "test/test_suite.bats"
$BATS "test/test_suite.bats"
RET=$?

curl_to_tricorder() {
Expand Down
11 changes: 8 additions & 3 deletions test/test_suite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# load bats-support
load 'libs/bats-support/load'
load 'libs/bats-assert/load'

@test 'fail()' {
fail 'this test always fails'
}

@test "Compare template and test TOML config files" {
# We skip the first 5 lines of the files as they contain the version and
Expand All @@ -14,14 +19,14 @@ load 'libs/bats-support/load'
@test "Running a second instance is detected and prevented" {
run bash -c 'su pihole -s /bin/sh -c "./pihole-FTL -f"'
printf "%s\n" "${lines[@]}"
[[ "${lines[@]}" == *"CRIT: pihole-FTL is already running"* ]]
assert_output --partial 'CRIT: pihole-FTL is already running'
}

@test "dnsmasq options as expected" {
run bash -c './pihole-FTL -vv | grep "cryptohash"'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "Features: IPv6 GNU-getopt no-DBus no-UBus no-i18n IDN2 DHCP DHCPv6 Lua TFTP no-conntrack ipset no-nftset auth cryptohash DNSSEC loop-detect inotify dumpfile" ]]
[[ ${lines[1]} == "" ]]
assert_line --index 0 "Features: IPv6 GNU-getopt no-DBus no-UBus no-i18n IDN2 DHCP DHCPv6 Lua TFTP no-conntrack ipset no-nftset auth cryptohash DNSSEC loop-detect inotify dumpfile"
assert_line --index 1 ''
}

@test "Initial blocking status is enabled" {
Expand Down

0 comments on commit d345655

Please sign in to comment.