diff --git a/packages/hurl/src/runner/body.rs b/packages/hurl/src/runner/body.rs index b9064e896..01391febc 100644 --- a/packages/hurl/src/runner/body.rs +++ b/packages/hurl/src/runner/body.rs @@ -89,25 +89,8 @@ mod tests { use super::*; - #[cfg(test)] - pub fn create_test_file() { - let path = Path::new("/tmp/data.bin"); - let display = path.display(); - if File::open(path).is_err() { - match File::create(&path) { - Err(why) => panic!("couldn't create {}: {:?}", display, why), - Ok(mut file) => match file.write_all(b"Hello World!") { - Err(why) => panic!("couldn't write to {}: {:?}", display, why), - Ok(_) => println!("successfully wrote to {}", display), - }, - } - } - } - #[test] pub fn test_body_file() { - create_test_file(); - // file, data.bin; let whitespace = Whitespace { value: String::from(" "), @@ -117,7 +100,7 @@ mod tests { let bytes = Bytes::File { space0: whitespace.clone(), filename: Filename { - value: String::from("/tmp/data.bin"), + value: String::from("tests/data.bin"), source_info: SourceInfo::init(1, 7, 1, 15), }, space1: whitespace.clone(), @@ -125,7 +108,7 @@ mod tests { let variables = HashMap::new(); assert_eq!( - eval_bytes(bytes, &variables, "current_dir".to_string()).unwrap(), + eval_bytes(bytes, &variables, ".".to_string()).unwrap(), b"Hello World!" ); } diff --git a/packages/hurl/tests/cookies.txt b/packages/hurl/tests/cookies.txt new file mode 100644 index 000000000..13c7e038f --- /dev/null +++ b/packages/hurl/tests/cookies.txt @@ -0,0 +1 @@ +localhost FALSE / FALSE 0 cookie2 valueA diff --git a/packages/hurl/tests/data.bin b/packages/hurl/tests/data.bin new file mode 100644 index 000000000..c57eff55e --- /dev/null +++ b/packages/hurl/tests/data.bin @@ -0,0 +1 @@ +Hello World! \ No newline at end of file diff --git a/packages/hurl/tests/libcurl.rs b/packages/hurl/tests/libcurl.rs index fb075a10d..becea4f00 100644 --- a/packages/hurl/tests/libcurl.rs +++ b/packages/hurl/tests/libcurl.rs @@ -1,5 +1,3 @@ -use std::fs::File; -use std::io::prelude::*; use std::time::Duration; use hurl::http::*; @@ -701,15 +699,10 @@ fn test_cookie_storage() { #[test] fn test_cookie_file() { - let temp_file = "/tmp/cookies"; - let mut file = File::create(temp_file).expect("can not create temp file!"); - file.write_all(b"localhost\tFALSE\t/\tFALSE\t0\tcookie2\tvalueA\n") - .unwrap(); - let options = ClientOptions { follow_location: false, max_redirect: None, - cookie_input_file: Some(temp_file.to_string()), + cookie_input_file: Some("tests/cookies.txt".to_string()), proxy: None, no_proxy: None, verbose: false,