mirror of https://github.com/hashicorp/packer
parent
85e615bbe2
commit
26c7ac2d90
@ -0,0 +1,33 @@
|
||||
package packer
|
||||
|
||||
// MockPostProcessor is an implementation of PostProcessor that can be
|
||||
// used for tests.
|
||||
type MockPostProcessor struct {
|
||||
ArtifactId string
|
||||
Keep bool
|
||||
Error error
|
||||
|
||||
ConfigureCalled bool
|
||||
ConfigureConfigs []interface{}
|
||||
ConfigureError error
|
||||
|
||||
PostProcessCalled bool
|
||||
PostProcessArtifact Artifact
|
||||
PostProcessUi Ui
|
||||
}
|
||||
|
||||
func (t *MockPostProcessor) Configure(configs ...interface{}) error {
|
||||
t.ConfigureCalled = true
|
||||
t.ConfigureConfigs = configs
|
||||
return t.ConfigureError
|
||||
}
|
||||
|
||||
func (t *MockPostProcessor) PostProcess(ui Ui, a Artifact) (Artifact, bool, error) {
|
||||
t.PostProcessCalled = true
|
||||
t.PostProcessArtifact = a
|
||||
t.PostProcessUi = ui
|
||||
|
||||
return &MockArtifact{
|
||||
IdValue: t.ArtifactId,
|
||||
}, t.Keep, t.Error
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package packer
|
||||
|
||||
type TestPostProcessor struct {
|
||||
artifactId string
|
||||
keep bool
|
||||
configCalled bool
|
||||
configVal []interface{}
|
||||
ppCalled bool
|
||||
ppArtifact Artifact
|
||||
ppUi Ui
|
||||
}
|
||||
|
||||
func (pp *TestPostProcessor) Configure(v ...interface{}) error {
|
||||
pp.configCalled = true
|
||||
pp.configVal = v
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pp *TestPostProcessor) PostProcess(ui Ui, a Artifact) (Artifact, bool, error) {
|
||||
pp.ppCalled = true
|
||||
pp.ppArtifact = a
|
||||
pp.ppUi = ui
|
||||
return &TestArtifact{id: pp.artifactId}, pp.keep, nil
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
{
|
||||
"builders": [{
|
||||
"type": "test"
|
||||
}],
|
||||
|
||||
"post-processors": ["test"]
|
||||
}
|
||||
Loading…
Reference in new issue