2013-05-22 01:10:21 -04:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2013-10-16 23:04:57 -04:00
|
|
|
"reflect"
|
2013-05-22 01:10:21 -04:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestArtifactRPC(t *testing.T) {
|
|
|
|
// Create the interface to test
|
2013-12-09 17:24:55 -05:00
|
|
|
a := new(packer.MockArtifact)
|
2013-05-22 01:10:21 -04:00
|
|
|
|
|
|
|
// Start the server
|
2013-12-09 19:22:11 -05:00
|
|
|
client, server := testClientServer(t)
|
|
|
|
defer client.Close()
|
|
|
|
defer server.Close()
|
2013-12-09 17:24:55 -05:00
|
|
|
server.RegisterArtifact(a)
|
2013-12-09 19:22:11 -05:00
|
|
|
|
2013-12-09 17:24:55 -05:00
|
|
|
aClient := client.Artifact()
|
2013-05-22 01:10:21 -04:00
|
|
|
|
|
|
|
// Test
|
2013-10-16 23:04:57 -04:00
|
|
|
if aClient.BuilderId() != "bid" {
|
|
|
|
t.Fatalf("bad: %s", aClient.BuilderId())
|
|
|
|
}
|
2013-05-22 01:10:21 -04:00
|
|
|
|
2013-10-16 23:04:57 -04:00
|
|
|
if !reflect.DeepEqual(aClient.Files(), []string{"a", "b"}) {
|
|
|
|
t.Fatalf("bad: %#v", aClient.Files())
|
|
|
|
}
|
2013-05-22 01:10:21 -04:00
|
|
|
|
2013-10-16 23:04:57 -04:00
|
|
|
if aClient.Id() != "id" {
|
|
|
|
t.Fatalf("bad: %s", aClient.Id())
|
|
|
|
}
|
2013-05-22 01:10:21 -04:00
|
|
|
|
2013-10-16 23:04:57 -04:00
|
|
|
if aClient.String() != "string" {
|
|
|
|
t.Fatalf("bad: %s", aClient.String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestArtifact_Implements(t *testing.T) {
|
2013-12-10 16:26:07 -05:00
|
|
|
var _ packer.Artifact = new(artifact)
|
2013-05-22 01:10:21 -04:00
|
|
|
}
|