github.com/opentofu/opentofu@v1.7.1/internal/command/e2etest/test_test.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package e2etest 7 8 import ( 9 "path/filepath" 10 "strings" 11 "testing" 12 "time" 13 14 "github.com/opentofu/opentofu/internal/e2e" 15 ) 16 17 func TestMultipleRunBlocks(t *testing.T) { 18 timeout := time.After(3 * time.Second) 19 type testResult struct { 20 stdout string 21 stderr string 22 err error 23 } 24 done := make(chan *testResult) 25 26 go func() { 27 fixturePath := filepath.Join("testdata", "multiple-run-blocks") 28 tf := e2e.NewBinary(t, tofuBin, fixturePath) 29 stdout, stderr, err := tf.Run("test") 30 done <- &testResult{ 31 stdout: stdout, 32 stderr: stderr, 33 err: err, 34 } 35 }() 36 37 select { 38 case <-timeout: 39 t.Fatal("timed out") 40 case result := <-done: 41 if result.err != nil { 42 t.Errorf("unexpected error: %s", result.err) 43 } 44 45 if result.stderr != "" { 46 t.Errorf("unexpected stderr output:\n%s", result.stderr) 47 } 48 49 if !strings.Contains(result.stdout, "30 passed") { 50 t.Errorf("success message is missing from output:\n%s", result.stdout) 51 } 52 } 53 }