github.com/jbronn/packer@v0.1.6-0.20140120165540-8a1364dbd817/packer/rpc/artifact_test.go (about)

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