2015-05-26 09:28:59 -07:00
|
|
|
package packer
|
|
|
|
|
2019-03-22 14:56:02 +01:00
|
|
|
import "context"
|
|
|
|
|
2015-05-26 09:28:59 -07:00
|
|
|
// MockPostProcessor is an implementation of PostProcessor that can be
|
|
|
|
// used for tests.
|
|
|
|
type MockPostProcessor struct {
|
2019-04-02 16:51:58 -07:00
|
|
|
ArtifactId string
|
|
|
|
Keep bool
|
|
|
|
ForceOverride bool
|
|
|
|
Error error
|
2015-05-26 09:28:59 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-04-08 19:59:42 +02:00
|
|
|
func (t *MockPostProcessor) PostProcess(ctx context.Context, ui Ui, a Artifact) (Artifact, bool, bool, error) {
|
2015-05-26 09:28:59 -07:00
|
|
|
t.PostProcessCalled = true
|
|
|
|
t.PostProcessArtifact = a
|
|
|
|
t.PostProcessUi = ui
|
|
|
|
|
|
|
|
return &MockArtifact{
|
|
|
|
IdValue: t.ArtifactId,
|
2019-04-02 16:51:58 -07:00
|
|
|
}, t.Keep, t.ForceOverride, t.Error
|
2015-05-26 09:28:59 -07:00
|
|
|
}
|