-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add CLI tests for version output (#664)
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function version() { | ||
boundary version -format json | ||
} | ||
|
||
function version_is_valid() { | ||
ver=$($(strip version) | jq -c '.version' | cut -d 'v' -f2) | ||
if [ "$ver" == "null" ]; then | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
function revision_is_valid() { | ||
len=$($(strip version) | jq -c '.revision' | cut -d '+' -f1 | wc -m) | ||
if [ "$len" -eq 42 ]; then | ||
return 0 | ||
fi | ||
return 1 | ||
} |
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,24 @@ | ||
#!/usr/bin/env bats | ||
|
||
load _helpers | ||
load _version | ||
|
||
export NEW_USER='test' | ||
|
||
@test "boundary/version: can run version command" { | ||
run version | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "boundary/version: version output is valid" { | ||
run version_is_valid | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "boundary/version: revision output is valid" { | ||
run revision_is_valid | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
} |