File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ impl RestPath<u16> for HttpBinDelay {
42
42
}
43
43
}
44
44
45
+ #[ derive( Serialize , Deserialize ) ]
46
+ struct HttpBinBase64 { }
47
+
48
+ impl RestPath < String > for HttpBinBase64 {
49
+ fn get_path ( data : String ) -> Result < String , Error > {
50
+ Ok ( format ! ( "base64/{}" , data) )
51
+ }
52
+ }
53
+
45
54
#[ test]
46
55
fn invalid_baseurl ( ) {
47
56
match RestClient :: new ( "1234" ) {
@@ -106,3 +115,18 @@ fn request_timeout() {
106
115
panic ! ( "expected timeout error" ) ;
107
116
}
108
117
}
118
+
119
+ #[ test]
120
+ fn deserialize_error ( ) {
121
+ let mut client = RestClient :: new ( "http://httpbin.org" ) . unwrap ( ) ;
122
+
123
+ // Service returns decoded base64 in body which should be string 'test'.
124
+ // This fails JSON deserialization and is returned in the Error
125
+ if let Err ( Error :: DeserializeParseError ( _, data) ) =
126
+ client. get :: < String , HttpBinBase64 > ( "dGVzdA==" . to_string ( ) )
127
+ {
128
+ assert ! ( data == "test" ) ;
129
+ } else {
130
+ panic ! ( "expected serialized error" ) ;
131
+ }
132
+ }
You can’t perform that action at this time.
0 commit comments