github.com/yoctocloud/packer@v0.6.2-0.20160520224004-e11a0a18423f/packer/artifact_mock.go (about) 1 package packer 2 3 // MockArtifact is an implementation of Artifact that can be used for tests. 4 type MockArtifact struct { 5 BuilderIdValue string 6 FilesValue []string 7 IdValue string 8 StateValues map[string]interface{} 9 DestroyCalled bool 10 } 11 12 func (a *MockArtifact) BuilderId() string { 13 if a.BuilderIdValue == "" { 14 return "bid" 15 } 16 17 return a.BuilderIdValue 18 } 19 20 func (a *MockArtifact) Files() []string { 21 if a.FilesValue == nil { 22 return []string{"a", "b"} 23 } 24 25 return a.FilesValue 26 } 27 28 func (a *MockArtifact) Id() string { 29 id := a.IdValue 30 if id == "" { 31 id = "id" 32 } 33 34 return id 35 } 36 37 func (*MockArtifact) String() string { 38 return "string" 39 } 40 41 func (a *MockArtifact) State(name string) interface{} { 42 value, _ := a.StateValues[name] 43 return value 44 } 45 46 func (a *MockArtifact) Destroy() error { 47 a.DestroyCalled = true 48 return nil 49 }