This repository was archived by the owner on Jul 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlogging_mock.go
More file actions
69 lines (54 loc) · 1.78 KB
/
logging_mock.go
File metadata and controls
69 lines (54 loc) · 1.78 KB
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 appwrap
import (
"net/http"
"github.com/stretchr/testify/mock"
)
type LoggingMock struct {
mock.Mock
Log Logging // all log calls are passed through to this logger (NullLogger may be used)
}
func (m *LoggingMock) ResetMock() {
m.Calls = make([]mock.Call, 0)
m.ExpectedCalls = make([]*mock.Call, 0)
}
func (m *LoggingMock) Debugf(format string, args ...interface{}) {
m.Mock.Called(append([]interface{}{format}, args...)...)
m.Log.Debugf(format, args...)
}
func (m *LoggingMock) Infof(format string, args ...interface{}) {
m.Mock.Called(append([]interface{}{format}, args...)...)
m.Log.Infof(format, args...)
}
func (m *LoggingMock) Warningf(format string, args ...interface{}) {
m.Mock.Called(append([]interface{}{format}, args...)...)
m.Log.Warningf(format, args...)
}
func (m *LoggingMock) Errorf(format string, args ...interface{}) {
m.Mock.Called(append([]interface{}{format}, args...)...)
m.Log.Errorf(format, args...)
}
func (m *LoggingMock) Criticalf(format string, args ...interface{}) {
m.Mock.Called(append([]interface{}{format}, args...)...)
m.Log.Criticalf(format, args...)
}
func (m *LoggingMock) Request(method, url, format string, args ...interface{}) {
m.Mock.Called(append([]interface{}{method, url, format}, args...)...)
m.Log.Request(method, url, format, args...)
}
func (m *LoggingMock) AddLabels(labels map[string]string) error {
m.Mock.Called(labels)
return m.Log.AddLabels(labels)
}
func (m *LoggingMock) TraceID() string {
return m.Mock.Called().String(0)
}
type LogServiceMock struct {
mock.Mock
}
func (m *LogServiceMock) CreateLog(labels map[string]string, logName LogName, r *http.Request, traceId string) Logging {
args := m.Mock.Called(labels, logName, r, traceId)
return args.Get(0).(Logging)
}
func (m *LogServiceMock) Close() {
m.Mock.Called()
}