github.com/amanya/packer@v0.12.1-0.20161117214323-902ac5ab2eb6/builder/cloudstack/artifact_test.go (about)

     1  package cloudstack
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/mitchellh/packer/packer"
     7  	"github.com/xanzy/go-cloudstack/cloudstack"
     8  )
     9  
    10  const templateID = "286dd44a-ec6b-4789-b192-804f08f04b4c"
    11  
    12  func TestArtifact_Impl(t *testing.T) {
    13  	var raw interface{} = &Artifact{}
    14  
    15  	if _, ok := raw.(packer.Artifact); !ok {
    16  		t.Fatalf("Artifact does not implement packer.Artifact")
    17  	}
    18  }
    19  
    20  func TestArtifactId(t *testing.T) {
    21  	a := &Artifact{
    22  		client: nil,
    23  		config: nil,
    24  		template: &cloudstack.CreateTemplateResponse{
    25  			Id: "286dd44a-ec6b-4789-b192-804f08f04b4c",
    26  		},
    27  	}
    28  
    29  	if a.Id() != templateID {
    30  		t.Fatalf("artifact ID should match: %s", templateID)
    31  	}
    32  }
    33  
    34  func TestArtifactString(t *testing.T) {
    35  	a := &Artifact{
    36  		client: nil,
    37  		config: nil,
    38  		template: &cloudstack.CreateTemplateResponse{
    39  			Name: "packer-foobar",
    40  		},
    41  	}
    42  	expected := "A template was created: packer-foobar"
    43  
    44  	if a.String() != expected {
    45  		t.Fatalf("artifact string should match: %s", expected)
    46  	}
    47  }