forked from martinbaillie/packer-plugin-ami-copy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-processor_test.go
57 lines (48 loc) · 1.08 KB
/
post-processor_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"bytes"
"testing"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/builder/amazon/ebs"
"github.com/hashicorp/packer/packer"
)
func TestPostProcessor_ImplementsPostProcessor(t *testing.T) {
var _ packer.PostProcessor = new(PostProcessor)
}
// TODO: AWS API mocking
// Stubs
func stubConfig() map[string]interface{} {
return map[string]interface{}{
"ami_users": []string{
"123456789104",
"123456789103",
"123456789102",
"123456789101",
},
"role_name": "AMICopyRole",
"encrypt_boot": true,
}
}
func stubPP(t *testing.T) *PostProcessor {
var p PostProcessor
if err := p.Configure(stubConfig()); err != nil {
t.Fatalf("err: %s", err)
}
return &p
}
func stubUI() *packer.BasicUi {
return &packer.BasicUi{
Reader: new(bytes.Buffer),
Writer: new(bytes.Buffer),
}
}
func stubArtifact() packer.Artifact {
artifact := &awscommon.Artifact{
BuilderIdValue: ebs.BuilderId,
Amis: map[string]string{
"ap-southeast-2": "ami-d2a666b0",
"us-west-1": "ami-d23104f1",
},
}
return artifact
}