From 53c8c1e2082edf45ecc066894d1fd346fbd55a13 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Mon, 30 Oct 2017 11:27:27 -0400 Subject: [PATCH 1/2] e2e test for `init -from-module` Pull down the hashicorp/vault/aws module into the current directory with init. --- command/e2etest/init_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/command/e2etest/init_test.go b/command/e2etest/init_test.go index f7eed5f2e..f14bf41bb 100644 --- a/command/e2etest/init_test.go +++ b/command/e2etest/init_test.go @@ -101,3 +101,37 @@ func TestInitProviders_pluginCache(t *testing.T) { t.Errorf("null plugin is not in cache after install") } } + +func TestInit_fromModule(t *testing.T) { + t.Parallel() + + // This test reaches out to registry.terraform.io and github.com to lookup + // and fetch a module. + skipIfCannotAccessNetwork(t) + + fixturePath := filepath.Join("test-fixtures", "empty") + tf := e2e.NewBinary(terraformBin, fixturePath) + defer tf.Close() + + cmd := tf.Cmd("init", "-from-module=hashicorp/vault/aws") + cmd.Stdin = nil + cmd.Stderr = &bytes.Buffer{} + + err := cmd.Run() + if err != nil { + t.Errorf("unexpected error: %s", err) + } + + stderr := cmd.Stderr.(*bytes.Buffer).String() + if stderr != "" { + t.Errorf("unexpected stderr output:\n%s", stderr) + } + + content, err := tf.ReadFile("main.tf") + if err != nil { + t.Fatalf("failed to read main.tf: %s", err) + } + if !bytes.Contains(content, []byte("vault")) { + t.Fatalf("main.tf doesn't appear to be a vault configuration: \n%s", content) + } +} From e24acc617cd887b54e35d26aedae09f8a13b9349 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Mon, 30 Oct 2017 14:04:25 -0400 Subject: [PATCH 2/2] force git to use https --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 61339bae5..a7a2876cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,10 @@ install: # See: https://github.com/golang/go/issues/12933 - bash scripts/gogetcookie.sh - go get github.com/kardianos/govendor + +before_script: +- git config --global url.https://github.com/.insteadOf ssh://git@github.com/ + script: - make vendor-status - make test