@@ -31,7 +31,7 @@ async fn echo_path<State>(req: tide::Request<State>) -> tide::Result<String> {
31
31
}
32
32
33
33
#[ async_std:: test]
34
- async fn route_middleware ( ) {
34
+ async fn route_middleware ( ) -> tide :: Result < ( ) > {
35
35
let mut app = tide:: new ( ) ;
36
36
let mut foo_route = app. at ( "/foo" ) ;
37
37
foo_route // /foo
@@ -46,17 +46,18 @@ async fn route_middleware() {
46
46
. reset_middleware ( )
47
47
. put ( echo_path) ;
48
48
49
- assert_eq ! ( app. get( "/foo" ) . await [ "X-Foo" ] , "foo" ) ;
50
- assert_eq ! ( app. post( "/foo" ) . await [ "X-Foo" ] , "foo" ) ;
51
- assert ! ( app. put( "/foo" ) . await . header( "X-Foo" ) . is_none( ) ) ;
49
+ assert_eq ! ( app. get( "/foo" ) . await ? [ "X-Foo" ] , "foo" ) ;
50
+ assert_eq ! ( app. post( "/foo" ) . await ? [ "X-Foo" ] , "foo" ) ;
51
+ assert ! ( app. put( "/foo" ) . await ? . header( "X-Foo" ) . is_none( ) ) ;
52
52
53
- let res = app. get ( "/foo/bar" ) . await ;
53
+ let res = app. get ( "/foo/bar" ) . await ? ;
54
54
assert_eq ! ( res[ "X-Foo" ] , "foo" ) ;
55
55
assert_eq ! ( res[ "x-bar" ] , "bar" ) ;
56
+ Ok ( ( ) )
56
57
}
57
58
58
59
#[ async_std:: test]
59
- async fn app_and_route_middleware ( ) {
60
+ async fn app_and_route_middleware ( ) -> tide :: Result < ( ) > {
60
61
let mut app = tide:: new ( ) ;
61
62
app. with ( TestMiddleware :: with_header_name ( "X-Root" , "root" ) ) ;
62
63
app. at ( "/foo" )
@@ -66,19 +67,20 @@ async fn app_and_route_middleware() {
66
67
. with ( TestMiddleware :: with_header_name ( "X-Bar" , "bar" ) )
67
68
. get ( echo_path) ;
68
69
69
- let res = app. get ( "/foo" ) . await ;
70
+ let res = app. get ( "/foo" ) . await ? ;
70
71
assert_eq ! ( res[ "X-Root" ] , "root" ) ;
71
72
assert_eq ! ( res[ "x-foo" ] , "foo" ) ;
72
73
assert ! ( res. header( "x-bar" ) . is_none( ) ) ;
73
74
74
- let res = app. get ( "/bar" ) . await ;
75
+ let res = app. get ( "/bar" ) . await ? ;
75
76
assert_eq ! ( res[ "X-Root" ] , "root" ) ;
76
77
assert ! ( res. header( "x-foo" ) . is_none( ) ) ;
77
78
assert_eq ! ( res[ "X-Bar" ] , "bar" ) ;
79
+ Ok ( ( ) )
78
80
}
79
81
80
82
#[ async_std:: test]
81
- async fn nested_app_with_route_middleware ( ) {
83
+ async fn nested_app_with_route_middleware ( ) -> tide :: Result < ( ) > {
82
84
let mut inner = tide:: new ( ) ;
83
85
inner. with ( TestMiddleware :: with_header_name ( "X-Inner" , "inner" ) ) ;
84
86
inner
@@ -95,23 +97,24 @@ async fn nested_app_with_route_middleware() {
95
97
. with ( TestMiddleware :: with_header_name ( "X-Bar" , "bar" ) )
96
98
. nest ( inner) ;
97
99
98
- let res = app. get ( "/foo" ) . await ;
100
+ let res = app. get ( "/foo" ) . await ? ;
99
101
assert_eq ! ( res[ "X-Root" ] , "root" ) ;
100
102
assert ! ( res. header( "X-Inner" ) . is_none( ) ) ;
101
103
assert_eq ! ( res[ "X-Foo" ] , "foo" ) ;
102
104
assert ! ( res. header( "X-Bar" ) . is_none( ) ) ;
103
105
assert ! ( res. header( "X-Baz" ) . is_none( ) ) ;
104
106
105
- let res = app. get ( "/bar/baz" ) . await ;
107
+ let res = app. get ( "/bar/baz" ) . await ? ;
106
108
assert_eq ! ( res[ "X-Root" ] , "root" ) ;
107
109
assert_eq ! ( res[ "X-Inner" ] , "inner" ) ;
108
110
assert ! ( res. header( "X-Foo" ) . is_none( ) ) ;
109
111
assert_eq ! ( res[ "X-Bar" ] , "bar" ) ;
110
112
assert_eq ! ( res[ "X-Baz" ] , "baz" ) ;
113
+ Ok ( ( ) )
111
114
}
112
115
113
116
#[ async_std:: test]
114
- async fn subroute_not_nested ( ) {
117
+ async fn subroute_not_nested ( ) -> tide :: Result < ( ) > {
115
118
let mut app = tide:: new ( ) ;
116
119
app. at ( "/parent" ) // /parent
117
120
. with ( TestMiddleware :: with_header_name ( "X-Parent" , "Parent" ) )
@@ -120,7 +123,8 @@ async fn subroute_not_nested() {
120
123
. with ( TestMiddleware :: with_header_name ( "X-Child" , "child" ) )
121
124
. get ( echo_path) ;
122
125
123
- let res = app. get ( "/parent/child" ) . await ;
126
+ let res = app. get ( "/parent/child" ) . await ? ;
124
127
assert ! ( res. header( "X-Parent" ) . is_none( ) ) ;
125
128
assert_eq ! ( res[ "x-child" ] , "child" ) ;
129
+ Ok ( ( ) )
126
130
}
0 commit comments