1
1
mod testcases;
2
2
3
3
mod integration_tests {
4
+ use reqwest:: Method ;
4
5
use sha2:: Digest ;
5
6
use std:: collections:: HashMap ;
6
7
@@ -23,10 +24,7 @@ mod integration_tests {
23
24
let spin = env. runtime_mut ( ) ;
24
25
assert_spin_request (
25
26
spin,
26
- testing_framework:: Request :: new (
27
- reqwest:: Method :: GET ,
28
- & format ! ( "/test?key={test_key}" ) ,
29
- ) ,
27
+ testing_framework:: Request :: new ( Method :: GET , & format ! ( "/test?key={test_key}" ) ) ,
30
28
testing_framework:: Response :: new_with_body ( 200 , test_value) ,
31
29
)
32
30
} ,
@@ -46,28 +44,25 @@ mod integration_tests {
46
44
let spin = env. runtime_mut ( ) ;
47
45
assert_spin_request (
48
46
spin,
49
- testing_framework:: Request :: new ( reqwest :: Method :: GET , "/test/hello" ) ,
47
+ testing_framework:: Request :: new ( Method :: GET , "/test/hello" ) ,
50
48
testing_framework:: Response :: new_with_body ( 200 , "I'm a teapot" ) ,
51
49
) ?;
52
50
assert_spin_request (
53
51
spin,
54
52
testing_framework:: Request :: new (
55
- reqwest :: Method :: GET ,
53
+ Method :: GET ,
56
54
"/test/hello/wildcards/should/be/handled" ,
57
55
) ,
58
56
testing_framework:: Response :: new_with_body ( 200 , "I'm a teapot" ) ,
59
57
) ?;
60
58
assert_spin_request (
61
59
spin,
62
- testing_framework:: Request :: new ( reqwest :: Method :: GET , "/thishsouldfail" ) ,
60
+ testing_framework:: Request :: new ( Method :: GET , "/thishsouldfail" ) ,
63
61
testing_framework:: Response :: new ( 404 ) ,
64
62
) ?;
65
63
assert_spin_request (
66
64
spin,
67
- testing_framework:: Request :: new (
68
- reqwest:: Method :: GET ,
69
- "/test/hello/test-placement" ,
70
- ) ,
65
+ testing_framework:: Request :: new ( Method :: GET , "/test/hello/test-placement" ) ,
71
66
testing_framework:: Response :: new_with_body ( 200 , "text for test" ) ,
72
67
)
73
68
} ,
@@ -152,7 +147,7 @@ mod integration_tests {
152
147
let spin = env. runtime_mut ( ) ;
153
148
assert_spin_request (
154
149
spin,
155
- testing_framework:: Request :: new ( reqwest :: Method :: GET , "/env" ) ,
150
+ testing_framework:: Request :: new ( Method :: GET , "/env" ) ,
156
151
testing_framework:: Response :: full (
157
152
200 ,
158
153
[
@@ -185,7 +180,7 @@ mod integration_tests {
185
180
assert_spin_request (
186
181
spin,
187
182
testing_framework:: Request :: new (
188
- reqwest :: Method :: GET ,
183
+ Method :: GET ,
189
184
& format ! ( "/static/thisshouldbemounted/{name}" ) ,
190
185
) ,
191
186
testing_framework:: Response :: new_with_body ( 200 , content) ,
@@ -203,10 +198,7 @@ mod integration_tests {
203
198
let mut assert_not_found = |path : & str | {
204
199
assert_spin_request (
205
200
spin,
206
- testing_framework:: Request :: new (
207
- reqwest:: Method :: GET ,
208
- & format ! ( "/static/{path}" ) ,
209
- ) ,
201
+ testing_framework:: Request :: new ( Method :: GET , & format ! ( "/static/{path}" ) ) ,
210
202
testing_framework:: Response :: new_with_body ( 404 , "Not Found" ) ,
211
203
)
212
204
} ;
@@ -233,7 +225,7 @@ mod integration_tests {
233
225
let mut test = |lang : & str , body : & str | {
234
226
assert_spin_request (
235
227
spin,
236
- testing_framework:: Request :: new ( reqwest :: Method :: GET , & format ! ( "/{lang}" ) ) ,
228
+ testing_framework:: Request :: new ( Method :: GET , & format ! ( "/{lang}" ) ) ,
237
229
testing_framework:: Response :: new_with_body ( 200 , body) ,
238
230
)
239
231
} ;
@@ -279,16 +271,13 @@ Caused by:
279
271
let spin = env. runtime_mut ( ) ;
280
272
assert_spin_request (
281
273
spin,
282
- testing_framework:: Request :: new ( reqwest :: Method :: GET , "/test/outbound-allowed" ) ,
274
+ testing_framework:: Request :: new ( Method :: GET , "/test/outbound-allowed" ) ,
283
275
testing_framework:: Response :: new_with_body ( 200 , "Hello, Fermyon!\n " ) ,
284
276
) ?;
285
277
286
278
assert_spin_request (
287
279
spin,
288
- testing_framework:: Request :: new (
289
- reqwest:: Method :: GET ,
290
- "/test/outbound-not-allowed" ,
291
- ) ,
280
+ testing_framework:: Request :: new ( Method :: GET , "/test/outbound-not-allowed" ) ,
292
281
testing_framework:: Response :: new ( 500 ) ,
293
282
) ?;
294
283
@@ -314,7 +303,7 @@ Caused by:
314
303
|env| {
315
304
let spin = env. runtime_mut ( ) ;
316
305
let mut ensure_success = |uri, expected_status, expected_body| {
317
- let request = testing_framework:: Request :: new ( reqwest :: Method :: GET , uri) ;
306
+ let request = testing_framework:: Request :: new ( Method :: GET , uri) ;
318
307
assert_spin_request (
319
308
spin,
320
309
request,
@@ -346,7 +335,7 @@ Caused by:
346
335
|env| {
347
336
let spin = env. runtime_mut ( ) ;
348
337
let mut ensure_success = |uri, expected_status, expected_body| {
349
- let request = testing_framework:: Request :: new ( reqwest :: Method :: GET , uri) ;
338
+ let request = testing_framework:: Request :: new ( Method :: GET , uri) ;
350
339
assert_spin_request (
351
340
spin,
352
341
request,
@@ -397,7 +386,7 @@ Caused by:
397
386
. status ( ) ;
398
387
assert_eq ! ( status, 200 ) ;
399
388
let spin = env. runtime_mut ( ) ;
400
- let request = testing_framework:: Request :: new ( reqwest :: Method :: GET , "/" ) ;
389
+ let request = testing_framework:: Request :: new ( Method :: GET , "/" ) ;
401
390
assert_spin_request (
402
391
spin,
403
392
request,
@@ -596,7 +585,7 @@ Caused by:
596
585
) ?;
597
586
assert_spin_request (
598
587
env. runtime_mut ( ) ,
599
- testing_framework:: Request :: new ( reqwest :: Method :: GET , "/" ) ,
588
+ testing_framework:: Request :: new ( Method :: GET , "/" ) ,
600
589
testing_framework:: Response :: new_with_body ( 200 , "Hello, Fermyon" ) ,
601
590
) ?;
602
591
Ok ( ( ) )
@@ -627,7 +616,7 @@ Caused by:
627
616
assert_spin_request (
628
617
env. runtime_mut ( ) ,
629
618
testing_framework:: Request :: full (
630
- reqwest :: Method :: GET ,
619
+ Method :: GET ,
631
620
"/" ,
632
621
& [ ( "url" , & format ! ( "http://127.0.0.1:{port}/" , ) ) ] ,
633
622
Some ( body. as_bytes ( ) ) ,
@@ -936,12 +925,8 @@ route = "/..."
936
925
headers. push ( ( "url" , & url) ) ;
937
926
}
938
927
let uri = format ! ( "/{uri}" ) ;
939
- let request = testing_framework:: Request :: full (
940
- reqwest:: Method :: POST ,
941
- & uri,
942
- & headers,
943
- Some ( body) ,
944
- ) ;
928
+ let request =
929
+ testing_framework:: Request :: full ( Method :: POST , & uri, & headers, Some ( body) ) ;
945
930
assert_spin_request (
946
931
spin,
947
932
request,
@@ -1008,7 +993,7 @@ route = "/..."
1008
993
. map ( |( k, v) | ( * k, v. as_str ( ) ) )
1009
994
. collect :: < Vec < _ > > ( ) ;
1010
995
let request = testing_framework:: Request :: full (
1011
- reqwest :: Method :: GET ,
996
+ Method :: GET ,
1012
997
"/hash-all" ,
1013
998
& headers,
1014
999
Option :: < Vec < u8 > > :: None ,
@@ -1063,7 +1048,7 @@ route = "/..."
1063
1048
assert_spin_request (
1064
1049
spin,
1065
1050
testing_framework:: Request :: full (
1066
- reqwest :: Method :: GET ,
1051
+ Method :: GET ,
1067
1052
"/base/echo" ,
1068
1053
& [ ] ,
1069
1054
Some ( "Echo..." ) ,
@@ -1106,7 +1091,7 @@ route = "/..."
1106
1091
) ;
1107
1092
let headers = [ ( "url" , service_url. as_str ( ) ) ] ;
1108
1093
let request: testing_framework:: Request < ' _ , Vec < u8 > > =
1109
- testing_framework:: Request :: full ( reqwest :: Method :: GET , "/" , & headers, None ) ;
1094
+ testing_framework:: Request :: full ( Method :: GET , "/" , & headers, None ) ;
1110
1095
let expected = testing_framework:: Response :: new_with_body ( 200 , "Hello, world!" ) ;
1111
1096
assert_spin_request ( env. runtime_mut ( ) , request, expected)
1112
1097
} ,
0 commit comments