forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_validator.go
43 lines (35 loc) · 1.01 KB
/
fake_validator.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
package fakes
import (
birelsetmanifest "github.com/cloudfoundry/bosh-cli/release/set/manifest"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type FakeValidator struct {
ValidateInputs []ValidateInput
validateOutputs []ValidateOutput
}
func NewFakeValidator() *FakeValidator {
return &FakeValidator{
ValidateInputs: []ValidateInput{},
validateOutputs: []ValidateOutput{},
}
}
type ValidateInput struct {
Manifest birelsetmanifest.Manifest
}
type ValidateOutput struct {
Err error
}
func (v *FakeValidator) Validate(manifest birelsetmanifest.Manifest) error {
v.ValidateInputs = append(v.ValidateInputs, ValidateInput{
Manifest: manifest,
})
if len(v.validateOutputs) == 0 {
return bosherr.Errorf("Unexpected FakeValidator.Validate(manifest) called with manifest: %#v", manifest)
}
validateOutput := v.validateOutputs[0]
v.validateOutputs = v.validateOutputs[1:]
return validateOutput.Err
}
func (v *FakeValidator) SetValidateBehavior(outputs []ValidateOutput) {
v.validateOutputs = outputs
}