@@ -8,7 +8,7 @@ use crate::clients::Client;
88use crate :: model:: TiledQuery ;
99
1010pub async fn graphql_handler < T : Client + Send + Sync + ' static > (
11- schema : Extension < Schema < TiledQuery < T > , EmptyMutation , EmptySubscription > > ,
11+ schema : Extension < Schema < TiledQuery , EmptyMutation , EmptySubscription > > ,
1212 req : GraphQLRequest ,
1313) -> GraphQLResponse {
1414 let query = req. into_inner ( ) . query ;
@@ -23,15 +23,27 @@ pub async fn graphiql_handler() -> impl IntoResponse {
2323#[ cfg( test) ]
2424mod tests {
2525 use async_graphql:: { EmptyMutation , EmptySubscription , Schema } ;
26+ use httpmock:: MockServer ;
27+ use url:: Url ;
2628
2729 use crate :: TiledQuery ;
28- use crate :: clients:: MockTiledClient ;
30+ use crate :: clients:: TiledClient ;
2931
3032 #[ tokio:: test]
3133 async fn test_api_version_query ( ) {
34+ let mock_server = MockServer :: start ( ) ;
35+
36+ let mock = mock_server
37+ . mock_async ( |when, then| {
38+ when. method ( "GET" ) . path ( "/api/v1/" ) ;
39+ then. status ( 200 )
40+ . body_from_file ( "resources/tiled_metadata.json" ) ;
41+ } )
42+ . await ;
43+
3244 let schema = Schema :: build (
33- TiledQuery ( MockTiledClient {
34- dir_path : "./resources" . into ( ) ,
45+ TiledQuery ( TiledClient {
46+ address : Url :: parse ( & mock_server . base_url ( ) ) . unwrap ( ) ,
3547 } ) ,
3648 EmptyMutation ,
3749 EmptySubscription ,
@@ -40,8 +52,7 @@ mod tests {
4052
4153 let response = schema. execute ( "{metadata { apiVersion } }" ) . await ;
4254
43- println ! ( "{:?}" , response. data. to_string( ) ) ;
44-
45- assert ! ( response. data. to_string( ) == "{metadata: {apiVersion: 0}}" )
55+ assert_eq ! ( response. data. to_string( ) , "{metadata: {apiVersion: 0}}" ) ;
56+ mock. assert ( ) ;
4657 }
4758}
0 commit comments