Dep init fails in my test package due to gruntwork-io/terratest constraints

I filed an issue in github, mods please delete this…

I am new to both Go and terratest and I got the beginnings of a helm test off the ground in an existing project with no other Go code. If I follow the directions here: GitHub - gruntwork-io/terratest: Terratest is a Go library that makes it easier to write automated tests for your infrastructure code. and run dep ensure -add github.com/gruntwork-io/terratest/modules/terraform I get “could not find project Gopkg.toml, use dep init to initiate a manifest”.

Then when I try to run dep init from my tests package directory, I get another error:

init failed: unable to solve the dependency graph: Solving failure: No versions of The Go Programming Language met constraints:
master: unable to update checked out version: fatal: reference is not a tree: 8e1b8d32e692162a446e97250c5d34f5a52efed6
: command failed: [git checkout 8e1b8d32e692162a446e97250c5d34f5a52efed6]: exit status 128
release-branch.go1.11: Could not introduce golang.org/x/crypto@release-branch.go1.11, as it is not allowed by constraint master from project GitHub - gruntwork-io/terratest: Terratest is a Go library that makes it easier to write automated tests for your infrastructure code..
release-branch.go1.12: Could not introduce golang.org/x/crypto@release-branch.go1.12, as it is not allowed by constraint master from project GitHub - gruntwork-io/terratest: Terratest is a Go library that makes it easier to write automated tests for your infrastructure code..

What am I missing?

Hi GwhorleyGH,

Here’s a simple example of getting this working…

$ mkdir myproj
$ cd my proj && mkdir test
$ cd test
$ vim example_test.go
    package test

    import (
      "testing"
      "github.com/stretchr/testify/assert"
    )

    func TestExample(t *testing.T) {
      t.Parallel()
      assert.Equal(t, "1", "1")
    }

$ dep init
$ dep ensure -add github.com/gruntwork-io/terratest/modules/terraform

"github.com/gruntwork-io/terratest/modules/terraform" is not imported by your project, and has been 
temporarily added to Gopkg.lock and vendor/. If you run "dep ensure" again before actually importing it, it will disappear from Gopkg.lock and vendor/. 

You should now be able to go into example_test.go and add terratest to the import. Also, make sure you actually use the import in your code or the next time you run dep ensure it will remove it from your Gopkg.toml and Gopkg.lock files.

Matt