Skip to content

Commit

Permalink
use currency snapshot in cli integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffany352 committed Jun 2, 2024
1 parent a1bcfa5 commit fc016a4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ mod tests {
Duration::from_millis(5),
);
let result = result.expect_err("this should always fail");
assert_eq!(result.to_string(), "[28] Timeout was reached (Operation timed out after 5 milliseconds with 0 bytes received)");
let result = result.to_string();
assert!(result.starts_with("[28] Timeout was reached (Operation timed out after "));
assert!(result.ends_with(" milliseconds with 0 bytes received)"));
thread_handle.join().unwrap();
drop(server);
}
Expand Down Expand Up @@ -541,7 +543,7 @@ mod tests {
let thread_handle = std::thread::spawn(move || {
let request = server2.recv().expect("the request should not fail");
assert_eq!(request.url(), "/data/currency.json");
let mut data = b"{}".to_owned();
let mut data = include_bytes!("../../core/tests/currency.snapshot.json").to_owned();
let cursor = std::io::Cursor::new(&mut data);
request
.respond(Response::new(StatusCode(200), vec![], cursor, None, None))
Expand All @@ -557,7 +559,10 @@ mod tests {
result
.read_to_string(&mut string)
.expect("the file should exist");
assert_eq!(string, "{}");
assert_eq!(
string,
include_str!("../../core/tests/currency.snapshot.json")
);
thread_handle.join().unwrap();
drop(server);
}
Expand All @@ -578,15 +583,15 @@ mod tests {
let thread_handle = std::thread::spawn(move || {
let request = server2.recv().expect("the request should not fail");
assert_eq!(request.url(), "/data/currency.json");
let mut data = b"{}".to_owned();
let mut data = include_bytes!("../../core/tests/currency.snapshot.json").to_owned();
let cursor = std::io::Cursor::new(&mut data);
request
.respond(Response::new(StatusCode(200), vec![], cursor, None, None))
.expect("the response should go through");
});
let result = super::force_refresh_currency(&config);
let result = result.expect("this should succeed");
assert!(result.starts_with("Fetched 2 byte currency file after "));
assert!(result.starts_with("Fetched 6599 byte currency file after "));
thread_handle.join().unwrap();
drop(server);
}
Expand Down

0 comments on commit fc016a4

Please sign in to comment.