aboutsummaryrefslogtreecommitdiff
path: root/src/routes/mod.rs
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2019-11-04 14:06:58 -0500
committerKevin J Hoerr <kjhoerr@protonmail.com>2019-11-04 14:06:58 -0500
commit4117f797cec89927fe3363543b8c8b11a311b90c (patch)
tree3f7320ee5a81a2e760c9f87991d63771633e5865 /src/routes/mod.rs
parent0c1dce106e0fb211cb52b2a780febd2a1b5f0a47 (diff)
downloadaugust-offensive-4117f797cec89927fe3363543b8c8b11a311b90c.tar.gz
august-offensive-4117f797cec89927fe3363543b8c8b11a311b90c.tar.bz2
august-offensive-4117f797cec89927fe3363543b8c8b11a311b90c.zip
Move FormatMsg to routes and add unit tests
Diffstat (limited to 'src/routes/mod.rs')
-rw-r--r--src/routes/mod.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/routes/mod.rs b/src/routes/mod.rs
index dd7a526..759375d 100644
--- a/src/routes/mod.rs
+++ b/src/routes/mod.rs
@@ -3,9 +3,11 @@ use actix_web::http::StatusCode;
use messages::*;
use std::collections::HashMap;
+pub mod format_msg;
mod callback;
mod not_understood;
+pub use self::format_msg::FormatMsg;
use self::callback::callback;
use self::not_understood::not_understood;
@@ -32,7 +34,7 @@ mod tests {
use super::*;
use actix_web::{http::Method, test::TestRequest};
use actix_web::{App, dev::Service, test::{block_on, init_service}};
- use actix_web::dev::{Body, ServiceResponse};
+ use actix_web::{HttpResponse, dev::Body};
use serde::Deserialize;
use std::str;
@@ -49,7 +51,7 @@ mod tests {
// Assert
assert_eq!(resp.status(), StatusCode::OK);
- let content = get_message::<OutgoingMsg<Callback>>(resp);
+ let content = get_message::<OutgoingMsg<Callback>>(resp.response());
assert_eq!(content.result_type, "CALLBACK");
assert_eq!(content.content.path, vec!["api", "callback"]);
}
@@ -67,7 +69,7 @@ mod tests {
// Assert
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
- let content = get_message::<OutgoingMsg<NotUnderstood>>(resp);
+ let content = get_message::<OutgoingMsg<NotUnderstood>>(resp.response());
assert_eq!(content.result_type, "NOT_UNDERSTOOD");
assert_eq!(content.content.path, vec!["api", "404"]);
}
@@ -137,8 +139,8 @@ mod tests {
Query::from_query(&query_str).unwrap()
}
- fn get_message<'a, T: Deserialize<'a>>(response: &'a ServiceResponse) -> T {
- let body = response.response().body().as_ref().unwrap();
+ pub fn get_message<'a, T: Deserialize<'a>>(response: &'a HttpResponse) -> T {
+ let body = response.body().as_ref().unwrap();
let mut array = &[b'0';0][..];
match body {
Body::Bytes(b) => {