aboutsummaryrefslogtreecommitdiff
path: root/tests/config-example/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/config-example/main.rs')
-rw-r--r--tests/config-example/main.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/config-example/main.rs b/tests/config-example/main.rs
index ed0f863..4b02c58 100644
--- a/tests/config-example/main.rs
+++ b/tests/config-example/main.rs
@@ -4,10 +4,18 @@ use std::process::Command;
use hyper::{body::aggregate, body::Buf, Body, Client, Method, Request, Uri};
+#[path = "../lib.rs"]
+mod helpers;
+use helpers::ChildExt;
+
#[tokio::test]
async fn main() {
let narchttpd_path = env!("CARGO_BIN_EXE_narchttpd");
- let mut narchttpd = Command::new(narchttpd_path).spawn().unwrap();
+ let _narchttpd = Command::new(narchttpd_path)
+ .current_dir("tests/config-example")
+ .spawn()
+ .unwrap()
+ .kill_on_drop();
let client = Client::new();
@@ -24,11 +32,11 @@ async fn main() {
.body(Body::empty())
.unwrap();
let res = client.request(req).await.unwrap();
- assert!(res.status().is_success());
+ assert!(res.status().is_success(), "{:?}", res);
let body = aggregate(res.into_body()).await.unwrap();
let mut result = String::new();
body.reader().read_to_string(&mut result).unwrap();
- result
+ result.trim().to_string()
};
assert_eq!(
@@ -45,6 +53,4 @@ async fn main() {
);
assert!(get("http://dynamic.test").await.contains("hello-there.txt"));
assert_eq!(get("http://function.test").await, "OK");
-
- narchttpd.kill().unwrap();
}