File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -100,4 +100,33 @@ mod tests {
100100 assert_eq ! ( response. errors. len( ) , 1 ) ;
101101 mock. assert ( ) ;
102102 }
103+
104+ #[ tokio:: test]
105+ async fn test_invalid_server_response ( ) {
106+ let mock_server = MockServer :: start ( ) ;
107+ let mock = mock_server
108+ . mock_async ( |when, then| {
109+ when. method ( "GET" ) . path ( "/api/v1/" ) ;
110+ then. status ( 200 ) . body ( "{}" ) ;
111+ } )
112+ . await ;
113+
114+ let schema = Schema :: build (
115+ TiledQuery ( TiledClient {
116+ address : Url :: parse ( & mock_server. base_url ( ) ) . unwrap ( ) ,
117+ } ) ,
118+ EmptyMutation ,
119+ EmptySubscription ,
120+ )
121+ . finish ( ) ;
122+
123+ let response = schema. execute ( "{metadata { apiVersion } }" ) . await ;
124+ assert_eq ! ( response. data, Value :: Null ) ;
125+ assert_eq ! ( response. errors. len( ) , 1 ) ;
126+ assert_eq ! (
127+ response. errors[ 0 ] . message,
128+ "Invalid response: missing field `api_version` at line 1 column 2, response: {}"
129+ ) ;
130+ mock. assert ( ) ;
131+ }
103132}
You can’t perform that action at this time.
0 commit comments