github.phpd.cn/hashicorp/packer@v1.3.2/builder/cloudstack/artifact_test.go (about) 1 package cloudstack 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/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 }