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
|
|
|
|
2020-11-19 15:17:11 -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
|
2020-11-20 13:21:29 -05:00
|
|
|
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()
|
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) {
|
2020-11-19 15:17:11 -05:00
|
|
|
var _ packersdk.Artifact = new(artifact)
|
2013-05-22 01:10:21 -04:00
|
|
|
}
|