From 42561cf7771cfb4a98e4d00476ba24735c789e03 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 6 Sep 2018 15:52:46 +0200 Subject: [PATCH] packer/rpc/ui_test.go: test progress bar too --- packer/rpc/ui_test.go | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/packer/rpc/ui_test.go b/packer/rpc/ui_test.go index 4dd2d7036..7b0489012 100644 --- a/packer/rpc/ui_test.go +++ b/packer/rpc/ui_test.go @@ -3,20 +3,23 @@ package rpc import ( "reflect" "testing" + + "github.com/hashicorp/packer/packer" ) type testUi struct { - askCalled bool - askQuery string - errorCalled bool - errorMessage string - machineCalled bool - machineType string - machineArgs []string - messageCalled bool - messageMessage string - sayCalled bool - sayMessage string + askCalled bool + askQuery string + errorCalled bool + errorMessage string + machineCalled bool + machineType string + machineArgs []string + messageCalled bool + messageMessage string + sayCalled bool + sayMessage string + progressBarCalled bool } func (u *testUi) Ask(query string) (string, error) { @@ -46,6 +49,11 @@ func (u *testUi) Say(message string) { u.sayMessage = message } +func (u *testUi) ProgressBar() packer.ProgressBar { + u.progressBarCalled = true + return new(packer.NoopProgressBar) +} + func TestUiRPC(t *testing.T) { // Create the UI to test ui := new(testUi) @@ -87,6 +95,10 @@ func TestUiRPC(t *testing.T) { if ui.sayMessage != "message" { t.Fatalf("bad: %#v", ui.errorMessage) } + uiClient.ProgressBar() + if ui.progressBarCalled != true { + t.Fatalf("ProgressBar not called.") + } uiClient.Machine("foo", "bar", "baz") if !ui.machineCalled {