From 227ab55617304e429cf8a2219c36bd1943ebd9bb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Jun 2013 17:40:21 -0700 Subject: [PATCH] builder/amazonebs: Artifact ID works --- builder/amazonebs/artifact.go | 10 +++++++--- builder/amazonebs/artifact_test.go | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/builder/amazonebs/artifact.go b/builder/amazonebs/artifact.go index ae3d44ef4..d2296bd07 100644 --- a/builder/amazonebs/artifact.go +++ b/builder/amazonebs/artifact.go @@ -25,9 +25,13 @@ func (*artifact) Files() []string { return nil } -func (*artifact) Id() string { - // TODO(mitchellh): Id - return "TODO" +func (a *artifact) Id() string { + parts := make([]string, 0, len(a.amis)) + for region, amiId := range a.amis { + parts = append(parts, fmt.Sprintf("%s:%s", region, amiId)) + } + + return strings.Join(parts, ",") } func (a *artifact) String() string { diff --git a/builder/amazonebs/artifact_test.go b/builder/amazonebs/artifact_test.go index a6ba75080..70888a8a8 100644 --- a/builder/amazonebs/artifact_test.go +++ b/builder/amazonebs/artifact_test.go @@ -13,6 +13,20 @@ func TestArtifact_Impl(t *testing.T) { assert.Implementor(&artifact{}, &actual, "should be an Artifact") } +func TestArtifactId(t *testing.T) { + assert := asserts.NewTestingAsserts(t, true) + + expected := `east:foo,west:bar` + + amis := make(map[string]string) + amis["east"] = "foo" + amis["west"] = "bar" + + a := &artifact{amis, nil} + result := a.Id() + assert.Equal(result, expected, "should match output") +} + func TestArtifactString(t *testing.T) { assert := asserts.NewTestingAsserts(t, true)