@@ -18,3 +18,52 @@ pub async fn test_rust_basic(wasm: &str) -> Result<()> {
1818 assert_eq ! ( headers. get( "x-served-by" ) . unwrap( ) , "land-edge" ) ;
1919 Ok ( ( ) )
2020}
21+
22+ pub async fn test_rust_fetch ( wasm : & str ) -> Result < ( ) > {
23+ let client = reqwest:: Client :: new ( ) ;
24+ let resp = client
25+ . get ( RUMTIME_SERVER )
26+ . header ( "x-land-module" , wasm)
27+ . send ( )
28+ . await ?;
29+ info ! ( "resp: {:?}" , resp) ;
30+ assert_eq ! ( resp. status( ) , 200 ) ;
31+ let body = resp. text ( ) . await ?;
32+ assert ! ( body. contains( "Rust Programming Language" ) ) ;
33+ Ok ( ( ) )
34+ }
35+
36+ pub async fn test_rust_router ( wasm : & str ) -> Result < ( ) > {
37+ let client = reqwest:: Client :: new ( ) ;
38+ let resp = client
39+ . get ( format ! ( "{}/hello" , RUMTIME_SERVER ) )
40+ . header ( "x-land-module" , wasm)
41+ . send ( )
42+ . await ?;
43+ info ! ( "resp: {:?}" , resp) ;
44+ assert_eq ! ( resp. status( ) , 200 ) ;
45+ let body = resp. text ( ) . await ?;
46+ assert_eq ! ( body, "Hello, World" ) ;
47+
48+ let resp = client
49+ . get ( format ! ( "{}/foo/bar" , RUMTIME_SERVER ) )
50+ . header ( "x-land-module" , wasm)
51+ . send ( )
52+ . await ?;
53+ info ! ( "resp: {:?}" , resp) ;
54+ assert_eq ! ( resp. status( ) , 200 ) ;
55+ let body = resp. text ( ) . await ?;
56+ assert_eq ! ( body, "Foo Bar" ) ;
57+
58+ let resp = client
59+ . get ( format ! ( "{}/params/xyz" , RUMTIME_SERVER ) )
60+ . header ( "x-land-module" , wasm)
61+ . send ( )
62+ . await ?;
63+ info ! ( "resp: {:?}" , resp) ;
64+ assert_eq ! ( resp. status( ) , 200 ) ;
65+ let body = resp. text ( ) . await ?;
66+ assert_eq ! ( body, "value: xyz" ) ;
67+
68+ Ok ( ( ) )
69+ }
0 commit comments