github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/packer/rpc/provisioner_test.go (about) 1 package rpc 2 3 import ( 4 "github.com/mitchellh/packer/packer" 5 "reflect" 6 "testing" 7 ) 8 9 func TestProvisionerRPC(t *testing.T) { 10 // Create the interface to test 11 p := new(packer.MockProvisioner) 12 13 // Start the server 14 client, server := testClientServer(t) 15 defer client.Close() 16 defer server.Close() 17 server.RegisterProvisioner(p) 18 pClient := client.Provisioner() 19 20 // Test Prepare 21 config := 42 22 pClient.Prepare(config) 23 if !p.PrepCalled { 24 t.Fatal("should be called") 25 } 26 expected := []interface{}{int64(42)} 27 if !reflect.DeepEqual(p.PrepConfigs, expected) { 28 t.Fatalf("bad: %#v", p.PrepConfigs) 29 } 30 31 // Test Provision 32 ui := &testUi{} 33 comm := &packer.MockCommunicator{} 34 pClient.Provision(ui, comm) 35 if !p.ProvCalled { 36 t.Fatal("should be called") 37 } 38 39 // Test Cancel 40 pClient.Cancel() 41 if !p.CancelCalled { 42 t.Fatal("cancel should be called") 43 } 44 } 45 46 func TestProvisioner_Implements(t *testing.T) { 47 var _ packer.Provisioner = new(provisioner) 48 }