#[allow(
dead_code,
reason = "one shared sandbox, three test targets, a subset used by each"
)]
mod common;
use common::{AMBIENT_CREDENTIALS, Sandbox, stderr, stdout};
use serde_json::json;
#[test]
fn a_source_with_no_credential_is_unavailable_however_the_host_that_runs_this_is_set_up() {
for name in AMBIENT_CREDENTIALS {
unsafe { std::env::set_var(name, "ambient-key-the-sandbox-must-not-pass-on") };
}
let sandbox = Sandbox::new();
sandbox.project_document(
&serde_json::to_string(&json!({
"sources": {"gone": {"plugin": "linear", "config": {}}}
}))
.expect("a one-source document"),
);
let listing = sandbox
.command()
.args(["sources", "list"])
.output()
.expect("the binary runs");
let rendered = stdout(&listing);
assert!(
rendered.contains("unavailable") && rendered.contains("LINEAR_API_KEY"),
"the source must still be reported unavailable, naming the variable it wanted:\n\
{rendered}{}",
stderr(&listing)
);
let listed = sandbox
.command()
.args(["task", "list"])
.output()
.expect("the binary runs");
assert_eq!(
listed.status.code(),
Some(4),
"a source that cannot be built must still cost exit 4:\n{}",
stderr(&listed)
);
assert!(
stderr(&listed).contains("gone"),
"and still name the source:\n{}",
stderr(&listed)
);
}