@@ -45,6 +45,24 @@ func NewTestSuite() TestSuite {
45
45
}
46
46
}
47
47
48
+ // NewTestRequest returns an initialized *TestRequest. It is used for extending
49
+ // testsuite package making it possibe to define own methods. Example:
50
+ // type MyTestSuite struct {
51
+ // testing.TestSuite
52
+ // }
53
+ //
54
+ // func (t *MyTestSuite) PutFormCustom(...) {
55
+ // req := http.NewRequest(...)
56
+ // ...
57
+ // return t.NewTestRequest(req)
58
+ // }
59
+ func (t * TestSuite ) NewTestRequest (req * http.Request ) * TestRequest {
60
+ return & TestRequest {
61
+ Request : req ,
62
+ testSuite : t ,
63
+ }
64
+ }
65
+
48
66
// Return the address and port of the server, e.g. "127.0.0.1:8557"
49
67
func (t * TestSuite ) Host () string {
50
68
if revel .Server .Addr [0 ] == ':' {
@@ -80,10 +98,7 @@ func (t *TestSuite) GetCustom(uri string) *TestRequest {
80
98
if err != nil {
81
99
panic (err )
82
100
}
83
- return & TestRequest {
84
- Request : req ,
85
- testSuite : t ,
86
- }
101
+ return t .NewTestRequest (req )
87
102
}
88
103
89
104
// Issue a DELETE request to the given path and store the result in Response and
@@ -98,10 +113,7 @@ func (t *TestSuite) DeleteCustom(uri string) *TestRequest {
98
113
if err != nil {
99
114
panic (err )
100
115
}
101
- return & TestRequest {
102
- Request : req ,
103
- testSuite : t ,
104
- }
116
+ return t .NewTestRequest (req )
105
117
}
106
118
107
119
// Issue a PUT request to the given path, sending the given Content-Type and
@@ -118,10 +130,7 @@ func (t *TestSuite) PutCustom(uri string, contentType string, reader io.Reader)
118
130
panic (err )
119
131
}
120
132
req .Header .Set ("Content-Type" , contentType )
121
- return & TestRequest {
122
- Request : req ,
123
- testSuite : t ,
124
- }
133
+ return t .NewTestRequest (req )
125
134
}
126
135
127
136
// Issue a PATCH request to the given path, sending the given Content-Type and
@@ -138,10 +147,7 @@ func (t *TestSuite) PatchCustom(uri string, contentType string, reader io.Reader
138
147
panic (err )
139
148
}
140
149
req .Header .Set ("Content-Type" , contentType )
141
- return & TestRequest {
142
- Request : req ,
143
- testSuite : t ,
144
- }
150
+ return t .NewTestRequest (req )
145
151
}
146
152
147
153
// Issue a POST request to the given path, sending the given Content-Type and
@@ -158,10 +164,7 @@ func (t *TestSuite) PostCustom(uri string, contentType string, reader io.Reader)
158
164
panic (err )
159
165
}
160
166
req .Header .Set ("Content-Type" , contentType )
161
- return & TestRequest {
162
- Request : req ,
163
- testSuite : t ,
164
- }
167
+ return t .NewTestRequest (req )
165
168
}
166
169
167
170
// Issue a POST request to the given path as a form post of the given key and
0 commit comments