builder/amazonebs: Artifact ID works

This commit is contained in:
Mitchell Hashimoto 2013-06-26 17:40:21 -07:00
parent 0f0041725e
commit 227ab55617
2 changed files with 21 additions and 3 deletions

View File

@ -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 {

View File

@ -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)