terraform: UIOutputPrefix

This commit is contained in:
Mitchell Hashimoto 2014-10-04 10:33:01 -07:00
parent b2342866c9
commit 24dd078bee
2 changed files with 39 additions and 0 deletions

View File

@ -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)
}

View File

@ -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)
}
}