packer-cn/packer/artifact_mock.go

55 lines
916 B
Go
Raw Normal View History

package packer
// MockArtifact is an implementation of Artifact that can be used for tests.
type MockArtifact struct {
2013-12-19 17:04:45 -05:00
BuilderIdValue string
FilesValue []string
IdValue string
StateValues map[string]interface{}
2013-12-19 17:04:45 -05:00
DestroyCalled bool
StringValue string
}
2013-12-19 17:04:45 -05:00
func (a *MockArtifact) BuilderId() string {
if a.BuilderIdValue == "" {
return "bid"
}
return a.BuilderIdValue
}
2013-12-19 17:04:45 -05:00
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
}