Give the ssh tests one bare host instead of two copies

Two tests built the same HostConfig inline -- a name, an address, and
nothing else configured. It is now `bare_host()`, named for what it is
about: the case that proves this adds no flags of its own when it was not
told to.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xn8nHw1tw1R6PtiY1eEtw
This commit is contained in:
irisandClaude Opus 5 committed 2026-08-28 03:21:58 -04:00
1 parent 3c4c728ed5
commit 9e11e860e5
1 file changed
+15 -14
+15 -14
View File
@@ -129,6 +129,19 @@ mod tests {
.collect()
}
/// A host with nothing configured but a name to dial, so `~/.ssh/config`
/// decides everything else -- the case that proves this adds no flags of
/// its own when it was not told to.
fn bare_host() -> HostConfig {
HostConfig {
name: "vm".to_string(),
address: "vm".to_string(),
port: None,
identity_file: None,
options: vec![],
}
}
#[test]
fn a_session_with_no_host_runs_the_command_directly() {
let command = command(
@@ -177,13 +190,7 @@ mod tests {
#[test]
fn a_remote_command_without_a_cwd_just_execs() {
let ssh = HostConfig {
name: "vm".to_string(),
address: "vm".to_string(),
port: None,
identity_file: None,
options: vec![],
};
let ssh = bare_host();
let rendered = argv(&command(Some(&ssh), "claude", &args(["-p"]), None));
assert_eq!(rendered.last().unwrap(), "exec 'claude' '-p'");
// No -i means no IdentitiesOnly: ~/.ssh/config decides instead.
@@ -200,13 +207,7 @@ mod tests {
// The end-to-end version of the same worry: a working directory
// that tries to close the quote and start a new command.
let ssh = HostConfig {
name: "vm".to_string(),
address: "vm".to_string(),
port: None,
identity_file: None,
options: vec![],
};
let ssh = bare_host();
let evil = Path::new("/tmp/'; touch /tmp/pwned; '");
let rendered = argv(&command(Some(&ssh), "claude", &[], Some(evil)));
let script = rendered.last().unwrap();