From 68341e6e8affb1a740415709cfb205b0bd55b21e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 4 May 2013 13:36:56 -0700 Subject: [PATCH] Test regisering a UI with the server --- packer/rpc/server_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packer/rpc/server_test.go b/packer/rpc/server_test.go index 4b65f5bd6..3c0e09e96 100644 --- a/packer/rpc/server_test.go +++ b/packer/rpc/server_test.go @@ -37,3 +37,24 @@ func TestServer_Start(t *testing.T) { _, err = rpc.Dial("tcp", addr) assert.NotNil(err, "should NOT be able to connect to RPC") } + +func TestServer_RegisterUi(t *testing.T) { + assert := asserts.NewTestingAsserts(t, true) + + ui := &testUi{} + + // Start the server with a UI + s := NewServer() + s.RegisterUi(ui) + assert.Nil(s.Start(), "should start properly") + defer s.Stop() + + // Verify it works + client, err := rpc.Dial("tcp", s.Address()) + assert.Nil(err, "should connect via RPC") + + uiClient := &Ui{client} + uiClient.Say("format") + + assert.Equal(ui.sayFormat, "format", "format should be correct") +}