terraform: UIOutputPrefix
This commit is contained in:
parent
b2342866c9
commit
24dd078bee
|
@ -0,0 +1,17 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// PrefixUIOutput is an implementation of UIOutput that prefixes the output
|
||||
// with a string.
|
||||
type PrefixUIOutput struct {
|
||||
Prefix string
|
||||
UIOutput UIOutput
|
||||
}
|
||||
|
||||
func (i *PrefixUIOutput) Output(v string) {
|
||||
v = fmt.Sprintf("%s%s", i.Prefix, v)
|
||||
i.UIOutput.Output(v)
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrefixUIOutput_impl(t *testing.T) {
|
||||
var _ UIOutput = new(PrefixUIOutput)
|
||||
}
|
||||
|
||||
func testPrefixUIOutput(t *testing.T) {
|
||||
output := new(MockUIOutput)
|
||||
prefix := &PrefixUIOutput{
|
||||
Prefix: "foo",
|
||||
UIOutput: output,
|
||||
}
|
||||
|
||||
prefix.Output("foo")
|
||||
if output.OutputMessage != "foofoo" {
|
||||
t.Fatalf("bad: %#v", output)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue