# shellcheck shell=bats load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" function local_setup_file() { ############ STACK_TRACE_BUILDER ##################### Function_Name="${FUNCNAME[0]}" Function_PATH="${Function_PATH}/${Function_Name}" ###################################################### setup_libs "helpers" ############### Stack_TRACE_BUILDER ################ Function_PATH="$( dirname ${Function_PATH} )" #################################################### } function setup_go_path() { ############ STACK_TRACE_BUILDER ##################### Function_Name="${FUNCNAME[0]}" Function_PATH="${Function_PATH}/${Function_Name}" ###################################################### local go_path="${1}" # Make sure that the requested GO folder is available assert_dir_exist "$go_path/bin" # Make sure that the requested GO folder is on the path export GOPATH="$go_path:${GOPATH:-}" ############### Stack_TRACE_BUILDER ################ Function_PATH="$( dirname ${Function_PATH} )" #################################################### } # 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' { { _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' { { _command_exists go && go version &>/dev/null; } || skip 'golang not found' setup_go_path "${BASH_IT}/test/fixtures/go/gopath" load ../../plugins/available/go.plugin assert_equal "$(cut -d':' -f1 <<<$PATH)" "${BASH_IT}/test/fixtures/go/gopath/bin" } @test 'plugins go: single entry in GOPATH, with space' { { _command_exists go && go version &>/dev/null; } || skip 'golang not found' setup_go_path "${BASH_IT}/test/fixtures/go/go path" load ../../plugins/available/go.plugin assert_equal "$(cut -d':' -f1 <<<$PATH)" "${BASH_IT}/test/fixtures/go/go path/bin" } @test 'plugins go: single entry in GOPATH, with escaped space' { skip 'huh?' { _command_exists go && go version &>/dev/null; } || skip 'golang not found' setup_go_path "${BASH_IT}/test/fixtures/go/go\ path" load ../../plugins/available/go.plugin assert_equal "$(cut -d':' -f1 <<<$PATH)" "${BASH_IT}/test/fixtures/go/go\ path/bin" } @test 'plugins go: multiple entries in GOPATH' { { _command_exists go && go version &>/dev/null; } || skip 'golang not found' setup_go_path "${BASH_IT}/test/fixtures/go/gopath" setup_go_path "${BASH_IT}/test/fixtures/go/gopath2" load ../../plugins/available/go.plugin assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "${BASH_IT}/test/fixtures/go/gopath2/bin:${BASH_IT}/test/fixtures/go/gopath/bin" } @test 'plugins go: multiple entries in GOPATH, with space' { { _command_exists go && go version &>/dev/null; } || skip 'golang not found' setup_go_path "${BASH_IT}/test/fixtures/go/gopath" setup_go_path "${BASH_IT}/test/fixtures/go/go path" load ../../plugins/available/go.plugin assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "${BASH_IT}/test/fixtures/go/go path/bin:${BASH_IT}/test/fixtures/go/gopath/bin" } @test 'plugins go: multiple entries in GOPATH, with escaped space' { skip 'huh?' { _command_exists go && go version &>/dev/null; } || skip 'golang not found' setup_go_path "${BASH_IT}/test/fixtures/go/gopath" setup_go_path "${BASH_IT}/test/fixtures/go/go path" load ../../plugins/available/go.plugin assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "${BASH_IT}/test/fixtures/go/go\ path/bin:${BASH_IT}/test/fixtures/go/gopath/bin" }