Skip to content

Commit 025df7f

Browse files
committed
tests + benches: adapt
1 parent a8ec72d commit 025df7f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

benches/repo.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use criterion::{black_box, criterion_group, criterion_main, Criterion};
22
use gix::{open, ThreadSafeRepository};
3-
use onefetch::{cli::CliOptions, info::build_info};
3+
use onefetch::{cli::CliOptions, config::ConfigOptions, info::build_info};
44

55
fn bench_repo_info(c: &mut Criterion) {
66
let name = "make_repo.sh".to_string();
@@ -10,10 +10,11 @@ fn bench_repo_info(c: &mut Criterion) {
1010
input: repo.path().to_path_buf(),
1111
..Default::default()
1212
};
13+
let toml = ConfigOptions::default();
1314

1415
c.bench_function("get repo information", |b| {
1516
b.iter(|| {
16-
let result = black_box(build_info(&config));
17+
let result = black_box(build_info(&config, &toml));
1718
assert!(result.is_ok());
1819
});
1920
});

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ mod test {
417417
let config: CliOptions = CliOptions {
418418
input: PathBuf::from("/tmp/folder"),
419419
info: InfoCliOptions {
420-
number_of_authors: 4,
420+
number_of_authors: Some(4),
421421
no_merges: Some(true),
422422
disabled_fields: vec![InfoType::Version, InfoType::URL].into(),
423423
..Default::default()

tests/repo.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use anyhow::Result;
22
use gix::{open, Repository, ThreadSafeRepository};
33
use onefetch::cli::{CliOptions, InfoCliOptions, TextFormattingCliOptions};
4+
use onefetch::config::ConfigOptions;
45
use onefetch::info::{build_info, get_work_dir};
56

67
fn repo(name: &str) -> Result<Repository> {
@@ -43,12 +44,13 @@ fn test_repo() -> Result<()> {
4344
..Default::default()
4445
},
4546
text_formatting: TextFormattingCliOptions {
46-
iso_time: true,
47+
iso_time: Some(true),
4748
..Default::default()
4849
},
4950
..Default::default()
5051
};
51-
let info = build_info(&config)?;
52+
let toml = ConfigOptions::default();
53+
let info = build_info(&config, &toml)?;
5254
insta::assert_json_snapshot!(
5355
info,
5456
{
@@ -67,7 +69,8 @@ fn test_repo_without_remote() -> Result<()> {
6769
input: repo.path().to_path_buf(),
6870
..Default::default()
6971
};
70-
let info = build_info(&config);
72+
let toml = ConfigOptions::default();
73+
let info = build_info(&config, &toml);
7174
assert!(info.is_ok());
7275

7376
Ok(())
@@ -80,7 +83,8 @@ fn test_partial_repo() -> Result<()> {
8083
input: repo.path().to_path_buf(),
8184
..Default::default()
8285
};
83-
let _info = build_info(&config).expect("no error");
86+
let toml = ConfigOptions::default();
87+
let _info = build_info(&config, &toml).expect("no error");
8488
Ok(())
8589
}
8690

@@ -91,6 +95,7 @@ fn test_repo_with_pre_epoch_dates() -> Result<()> {
9195
input: repo.path().to_path_buf(),
9296
..Default::default()
9397
};
94-
let _info = build_info(&config).expect("no error");
98+
let toml = ConfigOptions::default();
99+
let _info = build_info(&config, &toml).expect("no error");
95100
Ok(())
96101
}

0 commit comments

Comments
 (0)