summaryrefslogtreecommitdiff
path: root/src/gateway/http.rs
diff options
context:
space:
mode:
authorShaun Taheri <github@taheris.co.uk>2016-09-29 16:55:47 +0200
committerGitHub <noreply@github.com>2016-09-29 16:55:47 +0200
commita993b143fec9dee763366eba36681a276c4d47e7 (patch)
tree8d549735db8e9cd8c221999eb11d69b1cded38c8 /src/gateway/http.rs
parent484e98981f5ddbf61a9e4ca6190c9f2c2fcdec4c (diff)
parentb4d263c28fbc408d6dc2a437bd4a4affd5b6072e (diff)
downloadrvi_sota_client-a993b143fec9dee763366eba36681a276c4d47e7.tar.gz
Merge pull request #126 from advancedtelematic/feat/pro-1374/log-http-body-error
Return the HTTP Body when available
Diffstat (limited to 'src/gateway/http.rs')
-rw-r--r--src/gateway/http.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gateway/http.rs b/src/gateway/http.rs
index 6ccc2b5..f397630 100644
--- a/src/gateway/http.rs
+++ b/src/gateway/http.rs
@@ -91,7 +91,7 @@ mod tests {
use super::*;
use gateway::{Gateway, Interpret};
use datatype::{Command, Event};
- use http::{AuthClient, Client, set_ca_certificates};
+ use http::{AuthClient, Client, Response, set_ca_certificates};
#[test]
@@ -124,8 +124,12 @@ mod tests {
let url = "http://127.0.0.1:8888".parse().unwrap();
let body = json::encode(&cmd).unwrap();
let resp_rx = client.post(url, Some(body.into_bytes()));
- let resp = resp_rx.recv().unwrap().unwrap();
- let text = String::from_utf8(resp).unwrap();
+ let resp = resp_rx.recv().unwrap();
+ let text = match resp {
+ Response::Success(data) => String::from_utf8(data.body).unwrap(),
+ Response::Failed(data) => panic!("failed response: {}", data),
+ Response::Error(err) => panic!("error response: {}", err)
+ };
assert_eq!(json::decode::<Event>(&text).unwrap(),
Event::FoundSystemInfo(format!("{}", id)));
});