Merge pull request #1824 from cornfeedhobo/goenv-go

Ensure goenv and go play together well
This commit is contained in:
Noah Gorny
2021-02-06 00:14:07 +02:00
committed by GitHub
4 changed files with 69 additions and 37 deletions

View File

@@ -4,57 +4,51 @@ load ../test_helper
load ../../lib/helpers
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
@test 'ensure _go_pathmunge_wrap is defined' {
@test 'ensure _bash-it-gopath-pathmunge is defined' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
load ../../plugins/available/go.plugin
run type -t _go_pathmunge_wrap
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'
export GOPATH="/foo"
export GOROOT="/baz"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/baz/bin"
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'
export GOPATH="/foo bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo bar/bin:/baz/bin"
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'
export GOPATH="/foo\ bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo\ bar/bin:/baz/bin"
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo\ bar/bin"
}
@test 'plugins go: multiple entries in GOPATH' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
export GOPATH="/foo:/bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/bar/bin:/baz/bin"
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'
export GOPATH="/foo:/foo bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/foo bar/bin:/baz/bin"
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'
export GOPATH="/foo:/foo\ bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/foo\ bar/bin:/baz/bin"
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo\ bar/bin"
}