This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_noop_test.go
139 lines (109 loc) · 2.5 KB
/
client_noop_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
package geyser_test
import (
"net/http"
"net/url"
"time"
"github.com/13k/geyser/v2"
)
type NoopClient struct {
req *geyser.Request
res *geyser.Response
err error
cookies []*http.Cookie
jar http.CookieJar
debug bool
header http.Header
hostURL string
logger geyser.Logger
proxy string
query url.Values
retryCount int
retryMaxWait time.Duration
retryWait time.Duration
timeout time.Duration
transport http.RoundTripper
}
var _ geyser.Client = (*NoopClient)(nil)
func (c *NoopClient) Execute(req *geyser.Request) (*geyser.Response, error) {
c.req = req
return c.res, c.err
}
func (c *NoopClient) HostURL() string {
return c.hostURL
}
func (c *NoopClient) SetCookies(cookies []*http.Cookie) geyser.Client {
c.cookies = cookies
return c
}
func (c *NoopClient) SetCookieJar(jar http.CookieJar) geyser.Client {
c.jar = jar
return c
}
func (c *NoopClient) SetDebug(debug bool) geyser.Client {
c.debug = debug
return c
}
func (c *NoopClient) SetHeader(key string, value string) geyser.Client {
if c.header == nil {
c.header = make(http.Header)
}
c.header.Set(key, value)
return c
}
func (c *NoopClient) SetHeaders(header http.Header) geyser.Client {
if c.header == nil {
c.header = make(http.Header)
}
for k, v := range header {
c.header[k] = v
}
return c
}
func (c *NoopClient) SetHostURL(host string) geyser.Client {
c.hostURL = host
return c
}
func (c *NoopClient) SetLogger(logger geyser.Logger) geyser.Client {
c.logger = logger
return c
}
func (c *NoopClient) SetProxy(proxy string) geyser.Client {
c.proxy = proxy
return c
}
func (c *NoopClient) SetQueryParam(key string, value string) geyser.Client {
if c.query == nil {
c.query = make(url.Values)
}
c.query.Set(key, value)
return c
}
func (c *NoopClient) SetQueryParams(query url.Values) geyser.Client {
if c.query == nil {
c.query = make(url.Values)
}
for k, v := range query {
c.query[k] = v
}
return c
}
func (c *NoopClient) SetRetryCount(count int) geyser.Client {
c.retryCount = count
return c
}
func (c *NoopClient) SetRetryMaxWaitTime(maxWait time.Duration) geyser.Client {
c.retryMaxWait = maxWait
return c
}
func (c *NoopClient) SetRetryWaitTime(wait time.Duration) geyser.Client {
c.retryWait = wait
return c
}
func (c *NoopClient) SetTimeout(timeout time.Duration) geyser.Client {
c.timeout = timeout
return c
}
func (c *NoopClient) SetTransport(transport http.RoundTripper) geyser.Client {
c.transport = transport
return c
}