From 6445e1f16adbee95d0d57334736567b0420b29c7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 4 Oct 2014 09:00:07 -0700 Subject: [PATCH] terraform: UIOutput interface --- terraform/ui_output.go | 7 +++++++ terraform/ui_output_mock.go | 16 ++++++++++++++++ terraform/ui_output_mock_test.go | 9 +++++++++ 3 files changed, 32 insertions(+) create mode 100644 terraform/ui_output.go create mode 100644 terraform/ui_output_mock.go create mode 100644 terraform/ui_output_mock_test.go diff --git a/terraform/ui_output.go b/terraform/ui_output.go new file mode 100644 index 000000000..84427c63d --- /dev/null +++ b/terraform/ui_output.go @@ -0,0 +1,7 @@ +package terraform + +// UIOutput is the interface that must be implemented to output +// data to the end user. +type UIOutput interface { + Output(string) +} diff --git a/terraform/ui_output_mock.go b/terraform/ui_output_mock.go new file mode 100644 index 000000000..8e6ff82d7 --- /dev/null +++ b/terraform/ui_output_mock.go @@ -0,0 +1,16 @@ +package terraform + +// MockUIOutput is an implementation of UIOutput that can be used for tests. +type MockUIOutput struct { + OutputCalled bool + OutputMessage string + OutputFn func(string) +} + +func (o *MockUIOutput) Output(v string) { + o.OutputCalled = true + o.OutputMessage= v + if o.OutputFn == nil { + o.OutputFn(v) + } +} diff --git a/terraform/ui_output_mock_test.go b/terraform/ui_output_mock_test.go new file mode 100644 index 000000000..0a23c2e23 --- /dev/null +++ b/terraform/ui_output_mock_test.go @@ -0,0 +1,9 @@ +package terraform + +import ( + "testing" +) + +func TestMockUIOutput(t *testing.T) { + var _ UIOutput = new(MockUIOutput) +}