forked from hashicorp/packer
/
artifact_mock.go
54 lines (44 loc) · 919 Bytes
/
artifact_mock.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
package packer
// MockArtifact is an implementation of Artifact that can be used for tests.
type MockArtifact struct {
BuilderIdValue string
FilesValue []string
IdValue string
StateValues map[string]interface{}
DestroyCalled bool
StringValue string
}
func (a *MockArtifact) BuilderId() string {
if a.BuilderIdValue == "" {
return "bid"
}
return a.BuilderIdValue
}
func (a *MockArtifact) Files() []string {
if a.FilesValue == nil {
return []string{"a", "b"}
}
return a.FilesValue
}
func (a *MockArtifact) Id() string {
id := a.IdValue
if id == "" {
id = "id"
}
return id
}
func (a *MockArtifact) String() string {
str := a.StringValue
if str == "" {
str = "string"
}
return str
}
func (a *MockArtifact) State(name string) interface{} {
value, _ := a.StateValues[name]
return value
}
func (a *MockArtifact) Destroy() error {
a.DestroyCalled = true
return nil
}