Skip to content

Commit

Permalink
scope the handle drop test to eliminate shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
Quba1 committed Jan 27, 2024
1 parent dd34b89 commit d48b5a7
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions src/codes_handle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,35 +363,39 @@ mod tests {
async fn codes_handle_drop() {
testing_logger::setup();

let file_path = Path::new("./data/iceland-surface.grib");
let product_kind = ProductKind::GRIB;

let handle = CodesHandle::new_from_file(file_path, product_kind).unwrap();
drop(handle);
{
let file_path = Path::new("./data/iceland-surface.grib");
let product_kind = ProductKind::GRIB;

testing_logger::validate(|captured_logs| {
assert_eq!(captured_logs.len(), 0);
});
let handle = CodesHandle::new_from_file(file_path, product_kind).unwrap();
drop(handle);

let product_kind = ProductKind::GRIB;
let file_data = reqwest::get(
"https://github.com/ScaleWeather/eccodes/blob/main/data/iceland.grib?raw=true",
)
.await
.unwrap()
.bytes()
.await
.unwrap();
testing_logger::validate(|captured_logs| {
assert_eq!(captured_logs.len(), 0);
});
}

let handle = CodesHandle::new_from_memory(file_data, product_kind).unwrap();
drop(handle);

//logs from Reqwest are expected
testing_logger::validate(|captured_logs| {
for log in captured_logs {
assert_ne!(log.level, Level::Warn);
assert_ne!(log.level, Level::Error);
}
});
{
let product_kind = ProductKind::GRIB;
let file_data = reqwest::get(
"https://github.com/ScaleWeather/eccodes/blob/main/data/iceland.grib?raw=true",
)
.await
.unwrap()
.bytes()
.await
.unwrap();

let handle = CodesHandle::new_from_memory(file_data, product_kind).unwrap();
drop(handle);

//logs from Reqwest are expected
testing_logger::validate(|captured_logs| {
for log in captured_logs {
assert_ne!(log.level, Level::Warn);
assert_ne!(log.level, Level::Error);
}
});
}
}
}

0 comments on commit d48b5a7

Please sign in to comment.