diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-12-26 18:49:25 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-12-26 19:21:03 +0200 |
commit | abfeccd0d839eef9e90397dcff40f0bf918ed477 (patch) | |
tree | fefd20b8aa3da4d7771a46121fc03d8fb1c5dad0 /subplot | |
parent | 9f170606eb4fc24086274b446bb77cc1195280f0 (diff) | |
download | obnam-benchmark-abfeccd0d839eef9e90397dcff40f0bf918ed477.tar.gz |
feat: generate test data with junk contents
Also, add "obnam generate-junk" command, for testing this.
Sponsored-by: author
Diffstat (limited to 'subplot')
-rw-r--r-- | subplot/benchmark.rs | 17 | ||||
-rw-r--r-- | subplot/benchmark.yaml | 5 |
2 files changed, 22 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, + )?; +} diff --git a/subplot/benchmark.yaml b/subplot/benchmark.yaml index 70ebb54..dc3a136 100644 --- a/subplot/benchmark.yaml +++ b/subplot/benchmark.yaml @@ -12,3 +12,8 @@ impl: rust: function: file_is_valid_json + +- then: file {filename} is at least {number:int} bytes long + impl: + rust: + function: file_is_at_least_this_long |