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

terratest
#1

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: https://github.com/gruntwork-io/terratest#install 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 golang.org/x/crypto 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.com/gruntwork-io/terratest.
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.com/gruntwork-io/terratest.

What am I missing?

#2

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