github.com/hashicorp/terraform-plugin-sdk@v1.17.2/terraform/ui_output_provisioner_test.go (about) 1 package terraform 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/terraform-plugin-sdk/internal/addrs" 7 ) 8 9 func TestProvisionerUIOutput_impl(t *testing.T) { 10 var _ UIOutput = new(ProvisionerUIOutput) 11 } 12 13 func TestProvisionerUIOutputOutput(t *testing.T) { 14 hook := new(MockHook) 15 output := &ProvisionerUIOutput{ 16 InstanceAddr: addrs.Resource{ 17 Mode: addrs.ManagedResourceMode, 18 Type: "test_thing", 19 Name: "test", 20 }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance), 21 ProvisionerType: "foo", 22 Hooks: []Hook{hook}, 23 } 24 25 output.Output("bar") 26 27 if !hook.ProvisionOutputCalled { 28 t.Fatal("hook.ProvisionOutput was not called, and should've been") 29 } 30 if got, want := hook.ProvisionOutputProvisionerType, "foo"; got != want { 31 t.Fatalf("wrong provisioner type\ngot: %q\nwant: %q", got, want) 32 } 33 if got, want := hook.ProvisionOutputMessage, "bar"; got != want { 34 t.Fatalf("wrong output message\ngot: %q\nwant: %q", got, want) 35 } 36 }