-
Notifications
You must be signed in to change notification settings - Fork 18
/
builder_request.go
124 lines (97 loc) · 4.33 KB
/
builder_request.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
package cute
import (
"net/http"
"time"
)
// RequestRepeat is a function for set options in request
// if response.Code != Expect.Code, than request will repeat Count counts with Delay delay.
// Default delay is 1 second.
// Deprecated: use RequestRetry instead
func (qt *cute) RequestRepeat(count int) RequestHTTPBuilder {
qt.tests[qt.countTests].Request.Retry.Count = count
return qt
}
// RequestRepeatDelay set delay for request repeat.
// if response.Code != Expect.Code, than request will repeat Count counts with Delay delay.
// Default delay is 1 second.
// Deprecated: use RequestRetryDelay instead
func (qt *cute) RequestRepeatDelay(delay time.Duration) RequestHTTPBuilder {
qt.tests[qt.countTests].Request.Retry.Delay = delay
return qt
}
// RequestRepeatPolitic set politic for request repeat.
// if response.Code != Expect.Code, than request will repeat Count counts with Delay delay.
// if Optional is true and request is failed, than test step allure will be skipped, and t.Fail() will not execute.
// If Broken is true and request is failed, than test step allure will be broken, and t.Fail() will not execute.
// Deprecated: use RequestRetryPolitic instead
func (qt *cute) RequestRepeatPolitic(politic *RequestRepeatPolitic) RequestHTTPBuilder {
if politic == nil {
panic("politic is nil in RequestRetryPolitic")
}
qt.tests[qt.countTests].Request.Retry = &RequestRetryPolitic{
Count: politic.Count,
Delay: politic.Delay,
Optional: politic.Optional,
Broken: politic.Broken,
}
return qt
}
// RequestRepeatOptional set option politic for request repeat.
// if Optional is true and request is failed, than test step allure will be skipped, and t.Fail() will not execute.
// Deprecated: use RequestRetryOptional instead
func (qt *cute) RequestRepeatOptional(option bool) RequestHTTPBuilder {
qt.tests[qt.countTests].Request.Retry.Optional = option
return qt
}
// RequestRepeatBroken set broken politic for request repeat.
// If Broken is true and request is failed, than test step allure will be broken, and t.Fail() will not execute.
// Deprecated: use RequestRetryBroken instead
func (qt *cute) RequestRepeatBroken(broken bool) RequestHTTPBuilder {
qt.tests[qt.countTests].Request.Retry.Broken = broken
return qt
}
// RequestRetry is a function for set options in request
// if response.Code != Expect.Code, than request will repeat Count counts with Delay delay.
// Default delay is 1 second.
func (qt *cute) RequestRetry(count int) RequestHTTPBuilder {
qt.tests[qt.countTests].Request.Retry.Count = count
return qt
}
// RequestRetryDelay set delay for request repeat.
// if response.Code != Expect.Code, than request will repeat Count counts with Delay delay.
// Default delay is 1 second.
func (qt *cute) RequestRetryDelay(delay time.Duration) RequestHTTPBuilder {
qt.tests[qt.countTests].Request.Retry.Delay = delay
return qt
}
// RequestRetryPolitic set politic for request repeat.
// if response.Code != Expect.Code, than request will repeat Count counts with Delay delay.
// if Optional is true and request is failed, than test step allure will be skipped, and t.Fail() will not execute.
// If Broken is true and request is failed, than test step allure will be broken, and t.Fail() will not execute.
func (qt *cute) RequestRetryPolitic(politic *RequestRetryPolitic) RequestHTTPBuilder {
if politic == nil {
panic("politic is nil in RequestRetryPolitic")
}
qt.tests[qt.countTests].Request.Retry = politic
return qt
}
// RequestRetryOptional set option politic for request repeat.
// if Optional is true and request is failed, than test step allure will be skipped, and t.Fail() will not execute.
func (qt *cute) RequestRetryOptional(option bool) RequestHTTPBuilder {
qt.tests[qt.countTests].Request.Retry.Optional = option
return qt
}
// RequestRetryBroken set broken politic for request repeat.
// If Broken is true and request is failed, than test step allure will be broken, and t.Fail() will not execute.
func (qt *cute) RequestRetryBroken(broken bool) RequestHTTPBuilder {
qt.tests[qt.countTests].Request.Retry.Broken = broken
return qt
}
func (qt *cute) Request(r *http.Request) ExpectHTTPBuilder {
qt.tests[qt.countTests].Request.Base = r
return qt
}
func (qt *cute) RequestBuilder(r ...RequestBuilder) ExpectHTTPBuilder {
qt.tests[qt.countTests].Request.Builders = append(qt.tests[qt.countTests].Request.Builders, r...)
return qt
}