forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fake_applier.go
42 lines (33 loc) · 972 Bytes
/
fake_applier.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
package fakes
import (
models "github.com/cloudfoundry/bosh-agent/agent/applier/models"
)
type FakeApplier struct {
ActionsCalled []string
PreparedPackages []models.Package
PrepareError error
AppliedPackages []models.Package
ApplyError error
KeptOnlyPackages []models.Package
KeepOnlyErr error
}
func NewFakeApplier() *FakeApplier {
return &FakeApplier{
AppliedPackages: []models.Package{},
}
}
func (s *FakeApplier) Prepare(pkg models.Package) error {
s.ActionsCalled = append(s.ActionsCalled, "Prepare")
s.PreparedPackages = append(s.PreparedPackages, pkg)
return s.PrepareError
}
func (s *FakeApplier) Apply(pkg models.Package) error {
s.ActionsCalled = append(s.ActionsCalled, "Apply")
s.AppliedPackages = append(s.AppliedPackages, pkg)
return s.ApplyError
}
func (s *FakeApplier) KeepOnly(pkgs []models.Package) error {
s.ActionsCalled = append(s.ActionsCalled, "KeepOnly")
s.KeptOnlyPackages = pkgs
return s.KeepOnlyErr
}