This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
/
mock.go
69 lines (60 loc) · 1.69 KB
/
mock.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
62
63
64
65
66
67
68
69
package lights
import "context"
type MockLight struct {
AlertCalls map[string]int
OffCalls map[string]int
OnCalls map[string]int
RandomColorCalls map[string]int
SetBrightnessCalls map[string]int
SetColorCalls map[string]int
SetColorTempCalls map[string]int
}
func (m *MockLight) Alert(ctx context.Context, groupName string) error {
if len(m.AlertCalls) == 0 {
m.AlertCalls = make(map[string]int)
}
m.AlertCalls[groupName]++
return nil
}
func (m *MockLight) SetBrightness(ctx context.Context, groupName string, brightness int32) error {
if len(m.SetBrightnessCalls) == 0 {
m.SetBrightnessCalls = make(map[string]int)
}
m.SetBrightnessCalls[groupName]++
return nil
}
func (m *MockLight) Off(ctx context.Context, groupName string) error {
if len(m.OffCalls) == 0 {
m.OffCalls = make(map[string]int)
}
m.OffCalls[groupName]++
return nil
}
func (m *MockLight) On(ctx context.Context, groupName string) error {
if len(m.OnCalls) == 0 {
m.OnCalls = make(map[string]int)
}
m.OnCalls[groupName]++
return nil
}
func (m *MockLight) RandomColor(ctx context.Context, groupName string, colors []string) error {
if len(m.RandomColorCalls) == 0 {
m.RandomColorCalls = make(map[string]int)
}
m.RandomColorCalls[groupName]++
return nil
}
func (m *MockLight) SetColor(ctx context.Context, groupName string, hex string) error {
if len(m.SetColorCalls) == 0 {
m.SetColorCalls = make(map[string]int)
}
m.SetColorCalls[groupName]++
return nil
}
func (m *MockLight) SetColorTemp(ctx context.Context, groupName string, temp int32) error {
if len(m.SetColorTempCalls) == 0 {
m.SetColorTempCalls = make(map[string]int)
}
m.SetColorTempCalls[groupName]++
return nil
}