[英]Terratest does not find terraform on Mac
I am trying to write a simple go test as follows我正在尝试编写一个简单的 go 测试如下
import (
"testing"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
)
func TestCoreInfoOutput(t *testing.T) {
terraformOptions := &terraform.Options{
TerraformDir: "../examples/output.tf",
}
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
output := terraform.Output(t, terraformOptions, "test_name_prefix")
assert.Equal(t, "dev-use1-hello_world-", output)
}
But when I run go test my_test.go
I get the following error但是当我运行
go test my_test.go
出现以下错误
apply.go:13:
Error Trace: apply.go:13
my_test.go:17
Error: Received unexpected error:
FatalError{Underlying: fork/exec /usr/local/bin/terraform: not a directory}
Test: TestCoreInfoOutput
destroy.go:11:
Error Trace: destroy.go:11
panic.go:615
testing.go:657
apply.go:13
core-info_test.go:17
Error: Received unexpected error:
FatalError{Underlying: fork/exec /usr/local/bin/terraform: not a directory}
Test: my_Test
FAIL
Here is the folder structure这是文件夹结构
--module
--core-info
--examples
--core-info.tf
--output.tf
--test
my_test.go
I basically want to test the output values in output.tf in my test.我基本上想在我的测试中测试 output.tf 中的输出值。
EDIT:编辑:
After I changed the file to be a directory of the file it fails with the follwong error在我将文件更改为文件目录后,它因以下错误而失败
goroutine 23 [IO wait]:
internal/poll.runtime_pollWait(0x9804f28, 0x72, 0xffffffffffffffff)
/usr/local/go/src/runtime/netpoll.go:203 +0x55
internal/poll.(*pollDesc).wait(0xc00011c7f8, 0x72, 0x1001, 0x1000, 0xffffffffffffffff)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc00011c7e0, 0xc0001a6000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/internal/poll/fd_unix.go:169 +0x201
os.(*File).read(...)
/usr/local/go/src/os/file_unix.go:263
os.(*File).Read(0xc00011a080, 0xc0001a6000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/os/file.go:116 +0x71
bufio.(*Scanner).Scan(0xc000180300, 0x0)
/usr/local/go/src/bufio/scan.go:213 +0xa4
github.com/gruntwork-io/terratest/modules/shell.readData(0x13ebf20, 0xc00014a7e0, 0xc000180300, 0xc00011ebc0, 0xc00011eb88, 0xc00012d020)
/Users/me/go/src/github.com/gruntwork-io/terratest/modules/shell/command.go:151 +0xc9
created by github.com/gruntwork-io/terratest/modules/shell.readStdoutAndStderr
/Users/me/go/src/github.com/gruntwork-io/terratest/modules/shell/command.go:135 +0x257
FAIL command-line-arguments 600.060s
FAIL
TerraformDir
option should be set to a folder path and not a file path. TerraformDir
选项应设置为文件夹路径而不是文件路径。
TerraformDir: "../examples",
"../examples/output.tf"
is not a folder path "../examples/output.tf"
不是文件夹路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.