packer/rpc/ui_test.go: test progress bar too
This commit is contained in:
parent
5b66069da0
commit
42561cf777
|
@ -3,20 +3,23 @@ package rpc
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testUi struct {
|
type testUi struct {
|
||||||
askCalled bool
|
askCalled bool
|
||||||
askQuery string
|
askQuery string
|
||||||
errorCalled bool
|
errorCalled bool
|
||||||
errorMessage string
|
errorMessage string
|
||||||
machineCalled bool
|
machineCalled bool
|
||||||
machineType string
|
machineType string
|
||||||
machineArgs []string
|
machineArgs []string
|
||||||
messageCalled bool
|
messageCalled bool
|
||||||
messageMessage string
|
messageMessage string
|
||||||
sayCalled bool
|
sayCalled bool
|
||||||
sayMessage string
|
sayMessage string
|
||||||
|
progressBarCalled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *testUi) Ask(query string) (string, error) {
|
func (u *testUi) Ask(query string) (string, error) {
|
||||||
|
@ -46,6 +49,11 @@ func (u *testUi) Say(message string) {
|
||||||
u.sayMessage = message
|
u.sayMessage = message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *testUi) ProgressBar() packer.ProgressBar {
|
||||||
|
u.progressBarCalled = true
|
||||||
|
return new(packer.NoopProgressBar)
|
||||||
|
}
|
||||||
|
|
||||||
func TestUiRPC(t *testing.T) {
|
func TestUiRPC(t *testing.T) {
|
||||||
// Create the UI to test
|
// Create the UI to test
|
||||||
ui := new(testUi)
|
ui := new(testUi)
|
||||||
|
@ -87,6 +95,10 @@ func TestUiRPC(t *testing.T) {
|
||||||
if ui.sayMessage != "message" {
|
if ui.sayMessage != "message" {
|
||||||
t.Fatalf("bad: %#v", ui.errorMessage)
|
t.Fatalf("bad: %#v", ui.errorMessage)
|
||||||
}
|
}
|
||||||
|
uiClient.ProgressBar()
|
||||||
|
if ui.progressBarCalled != true {
|
||||||
|
t.Fatalf("ProgressBar not called.")
|
||||||
|
}
|
||||||
|
|
||||||
uiClient.Machine("foo", "bar", "baz")
|
uiClient.Machine("foo", "bar", "baz")
|
||||||
if !ui.machineCalled {
|
if !ui.machineCalled {
|
||||||
|
|
Loading…
Reference in New Issue