File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # This is a library which contains functions used inside ci/steps
4
+ #
5
+ # We separated it into it's own file so that we could easily unit test
6
+ # these functions and helpers
7
+
8
+ # Checks whether and environment variable is set.
9
+ # Source: https://stackoverflow.com/a/62210688/3015595
10
+ is_env_var_set () {
11
+ local name=" ${1:- } "
12
+ if test -n " ${! name:- } " ; then
13
+ echo 0
14
+ else
15
+ echo 1
16
+ fi
17
+ }
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bats
2
+
3
+ SCRIPT_NAME=" steps-lib.sh"
4
+ SCRIPT=" $BATS_TEST_DIRNAME /../../ci/steps/$SCRIPT_NAME "
5
+
6
+ source " $SCRIPT "
7
+
8
+ @test " is_env_var_set should return false if env var is not set" {
9
+ run is_env_var_set " ASDF_TEST_SET"
10
+ [ " $output " = 1 ]
11
+ }
12
+
13
+ @test " is_env_var_set should return true if env var is set" {
14
+ ASDF_TEST_SET=" test" run is_env_var_set " ASDF_TEST_SET"
15
+ [ " $output " = 0 ]
16
+ }
You can’t perform that action at this time.
0 commit comments