diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-12-26 17:21:49 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-12-26 17:21:49 +0000 |
commit | 010480a957c52e14172049aea3e692447be8cdfe (patch) | |
tree | fefd20b8aa3da4d7771a46121fc03d8fb1c5dad0 /subplot/benchmark.rs | |
parent | 9f170606eb4fc24086274b446bb77cc1195280f0 (diff) | |
parent | abfeccd0d839eef9e90397dcff40f0bf918ed477 (diff) | |
download | obnam-benchmark-010480a957c52e14172049aea3e692447be8cdfe.tar.gz |
Merge branch 'random' into 'main'
feat: generate test data with junk contents
See merge request obnam/obnam-benchmark!3
Diffstat (limited to 'subplot/benchmark.rs')
-rw-r--r-- | subplot/benchmark.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/subplot/benchmark.rs b/subplot/benchmark.rs index 566ce30..082e02b 100644 --- a/subplot/benchmark.rs +++ b/subplot/benchmark.rs @@ -72,3 +72,20 @@ fn read_json_file(filename: &Path) -> anyhow::Result<Value> { let file = File::open(filename)?; Ok(serde_json::from_reader(&file)?) } + +#[step] +#[context(Datadir)] +#[context(SubplotContext)] +fn file_is_at_least_this_long(context: &ScenarioContext, filename: &str, number: u64) { + context.with( + |context: &Datadir| { + let filename = context.canonicalise_filename(&filename)?; + let meta = std::fs::metadata(&filename)?; + if meta.len() < number { + panic!("file is {} bytes, wanted at least {} bytes", meta.len(), number); + } + Ok(()) + }, + false, + )?; +} |