Skip to content

Commit

Permalink
tests: add CLI tests for version output (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
malnick authored Oct 13, 2020
1 parent 342026b commit e08ab98
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/tests/cli/boundary/_version.bash
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
}
24 changes: 24 additions & 0 deletions internal/tests/cli/boundary/version.bats
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 ]
}

0 comments on commit e08ab98

Please sign in to comment.