github.phpd.cn/hashicorp/packer@v1.3.2/builder/alicloud/ecs/artifact_test.go (about) 1 package ecs 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/hashicorp/packer/packer" 8 ) 9 10 func TestArtifact_Impl(t *testing.T) { 11 var _ packer.Artifact = new(Artifact) 12 } 13 14 func TestArtifactId(t *testing.T) { 15 expected := `east:foo,west:bar` 16 17 ecsImages := make(map[string]string) 18 ecsImages["east"] = "foo" 19 ecsImages["west"] = "bar" 20 21 a := &Artifact{ 22 AlicloudImages: ecsImages, 23 } 24 25 result := a.Id() 26 if result != expected { 27 t.Fatalf("bad: %s", result) 28 } 29 } 30 31 func TestArtifactState_atlasMetadata(t *testing.T) { 32 a := &Artifact{ 33 AlicloudImages: map[string]string{ 34 "east": "foo", 35 "west": "bar", 36 }, 37 } 38 39 actual := a.State("atlas.artifact.metadata") 40 expected := map[string]string{ 41 "region.east": "foo", 42 "region.west": "bar", 43 } 44 if !reflect.DeepEqual(actual, expected) { 45 t.Fatalf("bad: %#v", actual) 46 } 47 }