forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfake_monit_client.go
61 lines (46 loc) · 1.4 KB
/
fake_monit_client.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package fakes
import (
boshmonit "github.com/cloudfoundry/bosh-agent/jobsupervisor/monit"
)
type FakeMonitClient struct {
ServicesInGroupName string
ServicesInGroupServices []string
ServicesInGroupErr error
StartServiceNames []string
StartServiceErr error
StopServiceNames []string
StopServiceErr error
UnmonitorServiceNames []string
UnmonitorServiceErrs []error
StatusStatus FakeMonitStatus
StatusErr error
Incarnations []int
StatusCalledTimes int
}
func NewFakeMonitClient() *FakeMonitClient {
return &FakeMonitClient{}
}
func (c *FakeMonitClient) ServicesInGroup(name string) ([]string, error) {
c.ServicesInGroupName = name
return c.ServicesInGroupServices, c.ServicesInGroupErr
}
func (c *FakeMonitClient) StartService(name string) error {
c.StartServiceNames = append(c.StartServiceNames, name)
return c.StartServiceErr
}
func (c *FakeMonitClient) StopService(name string) error {
c.StopServiceNames = append(c.StopServiceNames, name)
return c.StopServiceErr
}
func (c *FakeMonitClient) UnmonitorService(name string) error {
c.UnmonitorServiceNames = append(c.UnmonitorServiceNames, name)
return c.UnmonitorServiceErrs[len(c.UnmonitorServiceNames)-1]
}
func (c *FakeMonitClient) Status() (boshmonit.Status, error) {
s := c.StatusStatus
if len(c.Incarnations) > 0 {
s.Incarnation = c.Incarnations[c.StatusCalledTimes]
}
c.StatusCalledTimes++
return s, c.StatusErr
}