Search code examples
goterratest

Terratest utility pkg for func reuse


Folks is there a possibility to create utils.go amongst *_test.go in the terratest test package to utilize a func that performs certain common validation routines across all _test.go.

I tried creating utils/utils.go and within the *_test.go imported as "../tests/utils". This way able to run individual test like go test sample_test.go -v or go test another_sample_test.go -v and it yields.

But when I try go test -v it complains cannot reference a local package.

Am just a beginner to terratest and go lang in general. Any leads is greatly appreciated. Thanks.


Solution

  • Go packages must in general be imported by fully-qualified paths. The fully-qualified path for a package within your project depends on what module path you declare in your go.mod file.

    If you're new to Go, How to Write Go Code is a good place to start.