I am using BATS testing framework with bats-assert and bats-support.
I want to ensure that the user remembered to set the ELASTIC_CREDS env variable properly. How do I do that? Here is what I've tried:
config.bash
export SYSTEM_CREDS=myuser:mypass
Then, my checkcreds.bats test fike looks like this:
checkcreds.bats
#! ./libs/bats/bin/bats
load 'libs/bats-support/load'
load 'libs/bats-assert/load'
load 'config'
@test 'assert_system_creds()' {
run env | grep SYSTEM_CREDS | awk -F= '{print$2}'
assert_output --regexp '^.*:.*$'
}
This expression works fine:
@test 'check_env_vars()' {
run : ${SYSTEM_CREDS?"Need to set SYSTEM_CREDS"}
assert_success
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With