Skip to content

Commit

Permalink
fix installinator unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallagher committed Dec 7, 2023
1 parent af2a645 commit 8aba558
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions installinator-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ thiserror.workspace = true
tokio.workspace = true
update-engine.workspace = true
omicron-workspace-hack.workspace = true

[dev-dependencies]
proptest.workspace = true
test-strategy.workspace = true
15 changes: 14 additions & 1 deletion installinator-common/src/block_size_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ impl<W: AsyncWrite + Unpin> AsyncWrite for BlockSizeBufWriter<W> {
#[cfg(test)]
mod tests {
use super::*;
use crate::test_helpers::with_test_runtime;
use anyhow::Result;
use std::future::Future;
use test_strategy::proptest;
use tokio::io::AsyncWriteExt;

Expand Down Expand Up @@ -180,6 +180,19 @@ mod tests {
}
}

fn with_test_runtime<F, Fut, T>(f: F) -> T
where
F: FnOnce() -> Fut,
Fut: Future<Output = T>,
{
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_time()
.start_paused(true)
.build()
.expect("tokio Runtime built successfully");
runtime.block_on(f())
}

#[proptest]
fn proptest_block_writer(
chunks: Vec<Vec<u8>>,
Expand Down

0 comments on commit 8aba558

Please sign in to comment.