forked from Unleash/unleash-client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunleash_mock.go
49 lines (38 loc) · 833 Bytes
/
unleash_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
package unleash
import (
"encoding/json"
"net/http"
"github.com/stretchr/testify/mock"
)
const (
mockerServer = "http://foo.com"
mockAppName = "unleash-client-go-tests"
mockInstanceId = "1234"
)
type MockedListener struct {
mock.Mock
}
func (l *MockedListener) OnError(err error) {
l.Called(err)
}
func (l *MockedListener) OnWarning(warning error) {
l.Called(warning)
}
func (l *MockedListener) OnReady() {
l.Called()
}
func (l *MockedListener) OnCount(name string, enabled bool) {
l.Called(name, enabled)
}
func (l *MockedListener) OnSent(payload MetricsData) {
l.Called(payload)
}
func (l *MockedListener) OnRegistered(payload ClientData) {
l.Called(payload)
}
func writeJSON(rw http.ResponseWriter, x interface{}) {
enc := json.NewEncoder(rw)
if err := enc.Encode(x); err != nil {
panic(err)
}
}