github.com/sl1pm4t/terraform@v0.6.4-0.20170725213156-870617d22df3/command/e2etest/version_test.go (about) 1 package e2etest 2 3 import ( 4 "fmt" 5 "strings" 6 "testing" 7 8 tfcore "github.com/hashicorp/terraform/terraform" 9 ) 10 11 func TestVersion(t *testing.T) { 12 // Along with testing the "version" command in particular, this serves 13 // as a good smoke test for whether the Terraform binary can even be 14 // compiled and run, since it doesn't require any external network access 15 // to do its job. 16 17 t.Parallel() 18 19 tf := newTerraform("empty") 20 defer tf.Close() 21 22 stdout, stderr, err := tf.Run("version") 23 if err != nil { 24 t.Errorf("unexpected error: %s", err) 25 } 26 27 if stderr != "" { 28 t.Errorf("unexpected stderr output:\n%s", stderr) 29 } 30 31 wantVersion := fmt.Sprintf("Terraform %s", tfcore.VersionString()) 32 if strings.Contains(stdout, wantVersion) { 33 t.Errorf("output does not contain our current version %q:\n%s", wantVersion, stdout) 34 } 35 }