-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#!/usr/bin/env zunit | ||
|
||
@test 'Test loading script with global variable sets the variable' { | ||
load ./_support/script-with-global-variable; | ||
load ./_support/script-with-global-variable | ||
|
||
assert "$lost_city" equals 'Atlantis'; | ||
assert "$lost_city" equals 'Atlantis' | ||
} | ||
|
||
@test 'Test loading script with local variable does not set the variable' { | ||
load ./_support/script-with-local-variable; | ||
load ./_support/script-with-local-variable | ||
|
||
assert "$lost_city" is_empty; | ||
assert "$lost_city" is_empty | ||
} | ||
|
||
@test 'Test loading non-existent file throws error' { | ||
run load ./non-existent-script; | ||
run load ./non-existent-script | ||
|
||
assert "$state" equals 1; | ||
assert "$output" same_as 'File tests/./non-existent-script does not exist'; | ||
assert "$state" equals 1 | ||
assert "$output" same_as 'File tests/./non-existent-script does not exist' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env zunit | ||
|
||
@setup { | ||
echo 'Testing setup method' | ||
} | ||
|
||
@teardown { | ||
echo 'Testing teardown method' | ||
} | ||
|
||
@test 'Test successful command' { | ||
run return 0 | ||
|
||
assert $state equals 0 | ||
} | ||
|
||
@test 'Test unsuccessful command' { | ||
run return 1 | ||
|
||
assert $state equals 1 | ||
} | ||
|
||
@test 'Test non-existent command' { | ||
run a-non-existent-command | ||
|
||
assert $state equals 127 | ||
assert $output same_as 'run:19: command not found: a-non-existent-command' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env zunit | ||
|
||
@setup { | ||
SOME_VAR='rainbows' | ||
} | ||
|
||
@teardown { | ||
unset SOME_VAR | ||
} | ||
|
||
@test 'Check value of SOME_VAR' { | ||
assert $SOME_VAR same_as 'rainbows' | ||
} | ||
|
||
@test 'Change value of SOME_VAR' { | ||
SOME_VAR='unicorns' | ||
assert $SOME_VAR same_as 'unicorns' | ||
} | ||
|
||
@test 'Check value of SOME_VAR again' { | ||
# Check will fail, because the variable was unset in | ||
# the @teardown method, and then reset to 'rainbows' | ||
# when @setup was run again. | ||
run assert $SOME_VAR same_as 'unicorns' | ||
|
||
assert $state equals 1 | ||
} |