Skip to content

Commit b176adb

Browse files
committed
test: Added test cases about getting git/gitxide from Env and unstable table
1 parent 721cd55 commit b176adb

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
@@ -1923,3 +1923,51 @@ Caused by:
19231923
missing field `bax`",
19241924
);
19251925
}
1926+
1927+
#[cargo_test]
1928+
fn git_features_env() {
1929+
let gctx = GlobalContextBuilder::new()
1930+
.env("CARGO_UNSTABLE_GIT", "true")
1931+
.build();
1932+
verify(gctx);
1933+
1934+
write_config_toml(
1935+
"\
1936+
[unstable.git]
1937+
",
1938+
);
1939+
let gctx = GlobalContextBuilder::new().build();
1940+
verify(gctx);
1941+
1942+
fn verify(gctx: GlobalContext) {
1943+
assert_error(
1944+
gctx.get::<Option<cargo::core::CliUnstable>>("unstable")
1945+
.unwrap_err(),
1946+
"missing field `shallow_index`",
1947+
);
1948+
}
1949+
}
1950+
1951+
#[cargo_test]
1952+
fn gitoxide_features_env() {
1953+
let gctx = GlobalContextBuilder::new()
1954+
.env("CARGO_UNSTABLE_GITOXIDE", "true")
1955+
.build();
1956+
verify(gctx);
1957+
1958+
write_config_toml(
1959+
"\
1960+
[unstable.gitoxide]
1961+
",
1962+
);
1963+
let gctx = GlobalContextBuilder::new().build();
1964+
verify(gctx);
1965+
1966+
fn verify(gctx: GlobalContext) {
1967+
assert_error(
1968+
gctx.get::<Option<cargo::core::CliUnstable>>("unstable")
1969+
.unwrap_err(),
1970+
"missing field `fetch`",
1971+
);
1972+
}
1973+
}

0 commit comments

Comments
 (0)