Skip to content

Commit 1d19e76

Browse files
committed
test: Added test cases about getting git/gitxide from Env and unstable table
1 parent 5da2858 commit 1d19e76

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/testsuite/config.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,3 +1801,51 @@ fn trim_paths_parsing() {
18011801
let trim_paths: TomlTrimPaths = gctx.get("profile.dev.trim-paths").unwrap();
18021802
assert_eq!(trim_paths, expected, "failed to parse {val}");
18031803
}
1804+
1805+
#[cargo_test]
1806+
fn git_features_env() {
1807+
let gctx = GlobalContextBuilder::new()
1808+
.env("CARGO_UNSTABLE_GIT", "true")
1809+
.build();
1810+
verify(gctx);
1811+
1812+
write_config_toml(
1813+
"\
1814+
[unstable.git]
1815+
",
1816+
);
1817+
let gctx = GlobalContextBuilder::new().build();
1818+
verify(gctx);
1819+
1820+
fn verify(gctx: GlobalContext) {
1821+
assert_error(
1822+
gctx.get::<Option<cargo::core::CliUnstable>>("unstable")
1823+
.unwrap_err(),
1824+
"missing field `shallow_index`",
1825+
);
1826+
}
1827+
}
1828+
1829+
#[cargo_test]
1830+
fn gitoxide_features_env() {
1831+
let gctx = GlobalContextBuilder::new()
1832+
.env("CARGO_UNSTABLE_GITOXIDE", "true")
1833+
.build();
1834+
verify(gctx);
1835+
1836+
write_config_toml(
1837+
"\
1838+
[unstable.gitoxide]
1839+
",
1840+
);
1841+
let gctx = GlobalContextBuilder::new().build();
1842+
verify(gctx);
1843+
1844+
fn verify(gctx: GlobalContext) {
1845+
assert_error(
1846+
gctx.get::<Option<cargo::core::CliUnstable>>("unstable")
1847+
.unwrap_err(),
1848+
"missing field `fetch`",
1849+
);
1850+
}
1851+
}

0 commit comments

Comments
 (0)