packer-cn/packer/rpc/artifact_test.go

43 lines
817 B
Go
Raw Normal View History

2013-05-22 01:10:21 -04:00
package rpc
import (
2013-10-16 23:04:57 -04:00
"reflect"
2013-05-22 01:10:21 -04:00
"testing"
2018-01-22 20:21:10 -05:00
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
2013-05-22 01:10:21 -04:00
)
func TestArtifactRPC(t *testing.T) {
// Create the interface to test
a := new(packersdk.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()
server.RegisterArtifact(a)
2013-12-09 19:22:11 -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) {
var _ packersdk.Artifact = new(artifact)
2013-05-22 01:10:21 -04:00
}