Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip go tests when go is not available #1967

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions test/plugins/go.plugin.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,52 @@ load ../test_helper
load ../../lib/helpers
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"

# We test `go version` in each test to account for users with goenv and no system go.

@test 'ensure _bash-it-gopath-pathmunge is defined' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
load ../../plugins/available/go.plugin
run type -t _bash-it-gopath-pathmunge
assert_line 'function'
}

@test 'plugins go: single entry in GOPATH' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
export GOPATH="/foo"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo/bin"
}

@test 'plugins go: single entry in GOPATH, with space' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
export GOPATH="/foo bar"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo bar/bin"
}

@test 'plugins go: single entry in GOPATH, with escaped space' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
export GOPATH="/foo\ bar"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo\ bar/bin"
}

@test 'plugins go: multiple entries in GOPATH' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
export GOPATH="/foo:/bar"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/bar/bin"
}

@test 'plugins go: multiple entries in GOPATH, with space' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
export GOPATH="/foo:/foo bar"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo bar/bin"
}

@test 'plugins go: multiple entries in GOPATH, with escaped space' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
export GOPATH="/foo:/foo\ bar"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo\ bar/bin"
Expand Down