-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbus-bus-object_moq_test.go
181 lines (168 loc) · 4.67 KB
/
dbus-bus-object_moq_test.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package mpris
import (
"github.com/godbus/dbus/v5"
"sync"
)
// Ensure, that dbusBusObjectMock does implement dbusBusObject.
// If this is not the case, regenerate this file with moq.
var _ dbusBusObject = &dbusBusObjectMock{}
// dbusBusObjectMock is a mock implementation of dbusBusObject.
//
// func TestSomethingThatUsesdbusBusObject(t *testing.T) {
//
// // make and configure a mocked dbusBusObject
// mockeddbusBusObject := &dbusBusObjectMock{
// CallFunc: func(method string, flags dbus.Flags, args ...interface{}) dbusCall {
// panic("mock out the Call method")
// },
// GetPropertyFunc: func(p string) (dbus.Variant, error) {
// panic("mock out the GetProperty method")
// },
// SetPropertyFunc: func(p string, v interface{}) error {
// panic("mock out the SetProperty method")
// },
// }
//
// // use mockeddbusBusObject in code that requires dbusBusObject
// // and then make assertions.
//
// }
type dbusBusObjectMock struct {
// CallFunc mocks the Call method.
CallFunc func(method string, flags dbus.Flags, args ...interface{}) dbusCall
// GetPropertyFunc mocks the GetProperty method.
GetPropertyFunc func(p string) (dbus.Variant, error)
// SetPropertyFunc mocks the SetProperty method.
SetPropertyFunc func(p string, v interface{}) error
// calls tracks calls to the methods.
calls struct {
// Call holds details about calls to the Call method.
Call []struct {
// Method is the method argument value.
Method string
// Flags is the flags argument value.
Flags dbus.Flags
// Args is the args argument value.
Args []interface{}
}
// GetProperty holds details about calls to the GetProperty method.
GetProperty []struct {
// P is the p argument value.
P string
}
// SetProperty holds details about calls to the SetProperty method.
SetProperty []struct {
// P is the p argument value.
P string
// V is the v argument value.
V interface{}
}
}
lockCall sync.RWMutex
lockGetProperty sync.RWMutex
lockSetProperty sync.RWMutex
}
// Call calls CallFunc.
func (mock *dbusBusObjectMock) Call(method string, flags dbus.Flags, args ...interface{}) dbusCall {
if mock.CallFunc == nil {
panic("dbusBusObjectMock.CallFunc: method is nil but dbusBusObject.Call was just called")
}
callInfo := struct {
Method string
Flags dbus.Flags
Args []interface{}
}{
Method: method,
Flags: flags,
Args: args,
}
mock.lockCall.Lock()
mock.calls.Call = append(mock.calls.Call, callInfo)
mock.lockCall.Unlock()
return mock.CallFunc(method, flags, args...)
}
// CallCalls gets all the calls that were made to Call.
// Check the length with:
//
// len(mockeddbusBusObject.CallCalls())
func (mock *dbusBusObjectMock) CallCalls() []struct {
Method string
Flags dbus.Flags
Args []interface{}
} {
var calls []struct {
Method string
Flags dbus.Flags
Args []interface{}
}
mock.lockCall.RLock()
calls = mock.calls.Call
mock.lockCall.RUnlock()
return calls
}
// GetProperty calls GetPropertyFunc.
func (mock *dbusBusObjectMock) GetProperty(p string) (dbus.Variant, error) {
if mock.GetPropertyFunc == nil {
panic("dbusBusObjectMock.GetPropertyFunc: method is nil but dbusBusObject.GetProperty was just called")
}
callInfo := struct {
P string
}{
P: p,
}
mock.lockGetProperty.Lock()
mock.calls.GetProperty = append(mock.calls.GetProperty, callInfo)
mock.lockGetProperty.Unlock()
return mock.GetPropertyFunc(p)
}
// GetPropertyCalls gets all the calls that were made to GetProperty.
// Check the length with:
//
// len(mockeddbusBusObject.GetPropertyCalls())
func (mock *dbusBusObjectMock) GetPropertyCalls() []struct {
P string
} {
var calls []struct {
P string
}
mock.lockGetProperty.RLock()
calls = mock.calls.GetProperty
mock.lockGetProperty.RUnlock()
return calls
}
// SetProperty calls SetPropertyFunc.
func (mock *dbusBusObjectMock) SetProperty(p string, v interface{}) error {
if mock.SetPropertyFunc == nil {
panic("dbusBusObjectMock.SetPropertyFunc: method is nil but dbusBusObject.SetProperty was just called")
}
callInfo := struct {
P string
V interface{}
}{
P: p,
V: v,
}
mock.lockSetProperty.Lock()
mock.calls.SetProperty = append(mock.calls.SetProperty, callInfo)
mock.lockSetProperty.Unlock()
return mock.SetPropertyFunc(p, v)
}
// SetPropertyCalls gets all the calls that were made to SetProperty.
// Check the length with:
//
// len(mockeddbusBusObject.SetPropertyCalls())
func (mock *dbusBusObjectMock) SetPropertyCalls() []struct {
P string
V interface{}
} {
var calls []struct {
P string
V interface{}
}
mock.lockSetProperty.RLock()
calls = mock.calls.SetProperty
mock.lockSetProperty.RUnlock()
return calls
}