Merge pull request #1967 from cornfeedhobo/goenv-go-tests

skip go tests when go is not available
pull/1971/head
cornfeedhobo 2021-09-30 07:34:05 -05:00 committed by GitHub
commit 07384bcf7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -4,50 +4,52 @@ load ../test_helper
load ../../lib/helpers load ../../lib/helpers
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh" 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' { @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 load ../../plugins/available/go.plugin
run type -t _bash-it-gopath-pathmunge run type -t _bash-it-gopath-pathmunge
assert_line 'function' assert_line 'function'
} }
@test 'plugins go: single entry in GOPATH' { @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" export GOPATH="/foo"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo/bin" assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo/bin"
} }
@test 'plugins go: single entry in GOPATH, with space' { @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" export GOPATH="/foo bar"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo bar/bin" assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo bar/bin"
} }
@test 'plugins go: single entry in GOPATH, with escaped space' { @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" export GOPATH="/foo\ bar"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo\ bar/bin" assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo\ bar/bin"
} }
@test 'plugins go: multiple entries in GOPATH' { @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" export GOPATH="/foo:/bar"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/bar/bin" assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/bar/bin"
} }
@test 'plugins go: multiple entries in GOPATH, with space' { @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" export GOPATH="/foo:/foo bar"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo bar/bin" assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo bar/bin"
} }
@test 'plugins go: multiple entries in GOPATH, with escaped space' { @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" export GOPATH="/foo:/foo\ bar"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo\ bar/bin" assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo\ bar/bin"