github.com/HashDataInc/packer@v1.3.2/packer/rpc/artifact_test.go (about)

     1  package rpc
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/packer/packer"
     8  )
     9  
    10  func TestArtifactRPC(t *testing.T) {
    11  	// Create the interface to test
    12  	a := new(packer.MockArtifact)
    13  
    14  	// Start the server
    15  	client, server := testClientServer(t)
    16  	defer client.Close()
    17  	defer server.Close()
    18  	server.RegisterArtifact(a)
    19  
    20  	aClient := client.Artifact()
    21  
    22  	// Test
    23  	if aClient.BuilderId() != "bid" {
    24  		t.Fatalf("bad: %s", aClient.BuilderId())
    25  	}
    26  
    27  	if !reflect.DeepEqual(aClient.Files(), []string{"a", "b"}) {
    28  		t.Fatalf("bad: %#v", aClient.Files())
    29  	}
    30  
    31  	if aClient.Id() != "id" {
    32  		t.Fatalf("bad: %s", aClient.Id())
    33  	}
    34  
    35  	if aClient.String() != "string" {
    36  		t.Fatalf("bad: %s", aClient.String())
    37  	}
    38  }
    39  
    40  func TestArtifact_Implements(t *testing.T) {
    41  	var _ packer.Artifact = new(artifact)
    42  }