|
|
@@ -5,12 +5,53 @@ import (
|
|
5
|
5
|
"net"
|
|
6
|
6
|
"net/http/httptest"
|
|
7
|
7
|
"strings"
|
|
|
8
|
+ "time"
|
|
8
|
9
|
|
|
9
|
10
|
"github.com/mccutchen/go-httpbin/httpbin"
|
|
10
|
11
|
"github.com/stretchr/testify/mock"
|
|
11
|
12
|
"github.com/stretchr/testify/suite"
|
|
12
|
13
|
)
|
|
13
|
14
|
|
|
|
15
|
+type ConnMock struct {
|
|
|
16
|
+ mock.Mock
|
|
|
17
|
+}
|
|
|
18
|
+
|
|
|
19
|
+func (c *ConnMock) Read(b []byte) (int, error) {
|
|
|
20
|
+ args := c.Called(b)
|
|
|
21
|
+
|
|
|
22
|
+ return args.Int(0), args.Error(1)
|
|
|
23
|
+}
|
|
|
24
|
+
|
|
|
25
|
+func (c *ConnMock) Write(b []byte) (int, error) {
|
|
|
26
|
+ args := c.Called(b)
|
|
|
27
|
+
|
|
|
28
|
+ return args.Int(0), args.Error(1)
|
|
|
29
|
+}
|
|
|
30
|
+
|
|
|
31
|
+func (c *ConnMock) Close() error {
|
|
|
32
|
+ return c.Called().Error(0)
|
|
|
33
|
+}
|
|
|
34
|
+
|
|
|
35
|
+func (c *ConnMock) LocalAddr() net.Addr {
|
|
|
36
|
+ return c.Called().Get(0).(net.Addr)
|
|
|
37
|
+}
|
|
|
38
|
+
|
|
|
39
|
+func (c *ConnMock) RemoteAddr() net.Addr {
|
|
|
40
|
+ return c.Called().Get(0).(net.Addr)
|
|
|
41
|
+}
|
|
|
42
|
+
|
|
|
43
|
+func (c *ConnMock) SetDeadline(t time.Time) error {
|
|
|
44
|
+ return c.Called(t).Error(0)
|
|
|
45
|
+}
|
|
|
46
|
+
|
|
|
47
|
+func (c *ConnMock) SetReadDeadline(t time.Time) error {
|
|
|
48
|
+ return c.Called(t).Error(0)
|
|
|
49
|
+}
|
|
|
50
|
+
|
|
|
51
|
+func (c *ConnMock) SetWriteDeadline(t time.Time) error {
|
|
|
52
|
+ return c.Called(t).Error(0)
|
|
|
53
|
+}
|
|
|
54
|
+
|
|
14
|
55
|
type DialerMock struct {
|
|
15
|
56
|
mock.Mock
|
|
16
|
57
|
}
|