Skip to content

Commit

Permalink
test: Added test cases about getting git/gitxide from Env and unstabl…
Browse files Browse the repository at this point in the history
…e table
  • Loading branch information
linyihai committed Apr 8, 2024
1 parent 5da2858 commit 1d19e76
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/testsuite/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1801,3 +1801,51 @@ fn trim_paths_parsing() {
let trim_paths: TomlTrimPaths = gctx.get("profile.dev.trim-paths").unwrap();
assert_eq!(trim_paths, expected, "failed to parse {val}");
}

#[cargo_test]
fn git_features_env() {
let gctx = GlobalContextBuilder::new()
.env("CARGO_UNSTABLE_GIT", "true")
.build();
verify(gctx);

write_config_toml(
"\
[unstable.git]
",
);
let gctx = GlobalContextBuilder::new().build();
verify(gctx);

fn verify(gctx: GlobalContext) {
assert_error(
gctx.get::<Option<cargo::core::CliUnstable>>("unstable")
.unwrap_err(),
"missing field `shallow_index`",
);
}
}

#[cargo_test]
fn gitoxide_features_env() {
let gctx = GlobalContextBuilder::new()
.env("CARGO_UNSTABLE_GITOXIDE", "true")
.build();
verify(gctx);

write_config_toml(
"\
[unstable.gitoxide]
",
);
let gctx = GlobalContextBuilder::new().build();
verify(gctx);

fn verify(gctx: GlobalContext) {
assert_error(
gctx.get::<Option<cargo::core::CliUnstable>>("unstable")
.unwrap_err(),
"missing field `fetch`",
);
}
}

0 comments on commit 1d19e76

Please sign in to comment.