Skip to content

Instantly share code, notes, and snippets.

@constrict0r
Last active November 2, 2018 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save constrict0r/856f94478dc7faa74acf4d989d00a4cd to your computer and use it in GitHub Desktop.
Save constrict0r/856f94478dc7faa74acf4d989d00a4cd to your computer and use it in GitHub Desktop.
Bats sample test file.
#!./test/libs/bats/bin/bats
load 'libs/bats-support/load'
load 'libs/bats-assert/load'
setup() {
VAR1=0
}
@test "test setup function pass" {
[ $VAR1 -eq 0 ]
}
@test "test setup function fail" {
[ $VAR1 -eq 1 ]
}
@test "User is root" {
[ ! "$EUID" -ne 0 ]
}
@test "status var test pass" {
run echo "hello"
[ $status -eq 0 ]
}
@test "status var test fail" {
run echo "hello"
[ $status -eq 1 ]
}
@test "output var test pass" {
run echo "hello"
[ $output == "hello" ]
}
@test "output var test fail" {
run echo "hello"
[ $output == "hello2" ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment