github.com/opentofu/opentofu@v1.7.1/internal/legacy/tofu/ui_output_mock.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 tofu 7 8 import "sync" 9 10 // MockUIOutput is an implementation of UIOutput that can be used for tests. 11 type MockUIOutput struct { 12 sync.Mutex 13 OutputCalled bool 14 OutputMessage string 15 OutputFn func(string) 16 } 17 18 func (o *MockUIOutput) Output(v string) { 19 o.Lock() 20 defer o.Unlock() 21 o.OutputCalled = true 22 o.OutputMessage = v 23 if o.OutputFn != nil { 24 o.OutputFn(v) 25 } 26 }