packer-cn/packer/rpc/artifact_test.go

40 lines
754 B
Go
Raw Normal View History

2013-05-22 01:10:21 -04:00
package rpc
import (
"github.com/mitchellh/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
a := new(packer.MockArtifact)
2013-05-22 01:10:21 -04:00
// Start the server
server := NewServer()
server.RegisterArtifact(a)
client := testClient(t, server)
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) {
var _ packer.Artifact = Artifact(nil)
2013-05-22 01:10:21 -04:00
}