mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-27 16:26:40 +03:00
do not create test files in /tmp anymore
This commit is contained in:
parent
d8b01b928e
commit
836ad872a7
@ -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!"
|
||||
);
|
||||
}
|
||||
|
1
packages/hurl/tests/cookies.txt
Normal file
1
packages/hurl/tests/cookies.txt
Normal file
@ -0,0 +1 @@
|
||||
localhost FALSE / FALSE 0 cookie2 valueA
|
1
packages/hurl/tests/data.bin
Normal file
1
packages/hurl/tests/data.bin
Normal file
@ -0,0 +1 @@
|
||||
Hello World!
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user