github.com/opentofu/opentofu@v1.7.1/internal/command/e2etest/provisioner_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 "strings" 10 "testing" 11 12 "github.com/opentofu/opentofu/internal/e2e" 13 ) 14 15 // TestProviderDevOverrides is a test that tofu can execute a 3rd party 16 // provisioner plugin. 17 func TestProvisioner(t *testing.T) { 18 t.Parallel() 19 20 // This test reaches out to registry.opentofu.org to download the 21 // template and null providers, so it can only run if network access is 22 // allowed. 23 skipIfCannotAccessNetwork(t) 24 25 tf := e2e.NewBinary(t, tofuBin, "testdata/provisioner") 26 27 //// INIT 28 _, stderr, err := tf.Run("init") 29 if err != nil { 30 t.Fatalf("unexpected init error: %s\nstderr:\n%s", err, stderr) 31 } 32 33 //// PLAN 34 _, stderr, err = tf.Run("plan", "-out=tfplan") 35 if err != nil { 36 t.Fatalf("unexpected plan error: %s\nstderr:\n%s", err, stderr) 37 } 38 39 //// APPLY 40 stdout, stderr, err := tf.Run("apply", "tfplan") 41 if err != nil { 42 t.Fatalf("unexpected apply error: %s\nstderr:\n%s", err, stderr) 43 } 44 45 if !strings.Contains(stdout, "HelloProvisioner") { 46 t.Fatalf("missing provisioner output:\n%s", stdout) 47 } 48 }