github.com/sl1pm4t/terraform@v0.6.4-0.20170725213156-870617d22df3/command/e2etest/init_test.go (about) 1 package e2etest 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 func TestInitProviders(t *testing.T) { 9 t.Parallel() 10 11 // This test reaches out to releases.hashicorp.com to download the 12 // template provider, so it can only run if network access is allowed. 13 // We intentionally don't try to stub this here, because there's already 14 // a stubbed version of this in the "command" package and so the goal here 15 // is to test the interaction with the real repository. 16 skipIfCannotAccessNetwork(t) 17 18 tf := newTerraform("template-provider") 19 defer tf.Close() 20 21 stdout, stderr, err := tf.Run("init") 22 if err != nil { 23 t.Errorf("unexpected error: %s", err) 24 } 25 26 if stderr != "" { 27 t.Errorf("unexpected stderr output:\n%s", stderr) 28 } 29 30 if !strings.Contains(stdout, "Terraform has been successfully initialized!") { 31 t.Errorf("success message is missing from output:\n%s", stdout) 32 } 33 34 if !strings.Contains(stdout, "- Downloading plugin for provider \"template\"") { 35 t.Errorf("provider download message is missing from output:\n%s", stdout) 36 t.Logf("(this can happen if you have a copy of the plugin in one of the global plugin search dirs)") 37 } 38 39 if !strings.Contains(stdout, "* provider.template: version = ") { 40 t.Errorf("provider pinning recommendation is missing from output:\n%s", stdout) 41 } 42 43 }