Skip to content

Commit 11d7e8e

Browse files
Merge branch 'main' into integration
2 parents 14abf58 + 2011483 commit 11d7e8e

16 files changed

+83
-184
lines changed

Cargo.lock

Lines changed: 2 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ resolver = "2"
1212

1313
[workspace.dependencies]
1414
anyhow = "1.0.100"
15-
assert_cmd = "2.0.17"
15+
assert_cmd = "2.1.1"
1616
async-trait = "0.1.89"
1717
base64 = "0.22.1"
1818
built = { version = "0.8.0", features = ["git2"] }

cli/src/cmd_auth.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -638,31 +638,6 @@ fn create_private_file(path: &Path) -> Result<File> {
638638

639639
#[cfg(test)]
640640
mod tests {
641-
#[test]
642-
fn test_cmd_auth_login() {
643-
use assert_cmd::Command;
644-
use predicates::str;
645-
646-
let temp_dir = tempfile::tempdir().unwrap();
647-
648-
let bad_url = "sys.oxide.invalid";
649-
650-
// Validate connection error details are printed
651-
Command::cargo_bin("oxide")
652-
.unwrap()
653-
.arg("--config-dir")
654-
.arg(temp_dir.path().as_os_str())
655-
.arg("auth")
656-
.arg("login")
657-
.arg("--host")
658-
.arg(bad_url)
659-
.assert()
660-
.failure()
661-
.stderr(str::starts_with(
662-
"Request failed: client error: error sending request",
663-
));
664-
}
665-
666641
#[test]
667642
fn test_parse_host() {
668643
use super::parse_host;

cli/src/cmd_version.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,3 @@ impl RunnableCmd for CmdVersion {
4545
Ok(())
4646
}
4747
}
48-
49-
#[test]
50-
fn version_success() {
51-
use assert_cmd::Command;
52-
53-
let mut cmd = Command::cargo_bin("oxide").unwrap();
54-
let cli_version = built_info::PKG_VERSION;
55-
let api_version = Client::api_version();
56-
57-
cmd.arg("version");
58-
cmd.assert().success().stdout(format!(
59-
"Oxide CLI {}\nBuilt from commit: {} {}\nOxide API: {}\n",
60-
cli_version,
61-
built_info::GIT_COMMIT_HASH.unwrap(),
62-
if matches!(built_info::GIT_DIRTY, Some(true)) {
63-
"(dirty)"
64-
} else {
65-
""
66-
},
67-
api_version,
68-
));
69-
}

cli/tests/test_api.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// Copyright 2023 Oxide Computer Company
66

7-
use assert_cmd::Command;
87
use httpmock::prelude::*;
98
use predicates::prelude::*;
109
use serde::Serialize;
@@ -28,8 +27,7 @@ fn test_simple_api_call() {
2827
));
2928
});
3029

31-
Command::cargo_bin("oxide")
32-
.unwrap()
30+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
3331
.env("OXIDE_HOST", server.url(""))
3432
.env("OXIDE_TOKEN", "fake-token")
3533
.arg("api")
@@ -38,8 +36,7 @@ fn test_simple_api_call() {
3836
.success()
3937
.stdout(predicate::str::diff("{\n \"a\": \"b\"\n}\n"));
4038

41-
Command::cargo_bin("oxide")
42-
.unwrap()
39+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
4340
.env("OXIDE_HOST", server.url(""))
4441
.env("OXIDE_TOKEN", "fake-token")
4542
.arg("api")
@@ -141,8 +138,7 @@ fn test_pagination_success() {
141138
];
142139
let output_str = format!("{}\n", serde_json::to_string_pretty(&output).unwrap());
143140

144-
Command::cargo_bin("oxide")
145-
.unwrap()
141+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
146142
.env("OXIDE_HOST", server.url(""))
147143
.env("OXIDE_TOKEN", "fake-token")
148144
.arg("api")
@@ -211,8 +207,7 @@ fn test_pagination_midway_failure() {
211207
"HTTP status client error (404 Not Found)",
212208
);
213209

214-
Command::cargo_bin("oxide")
215-
.unwrap()
210+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
216211
.env("OXIDE_HOST", server.url(""))
217212
.env("OXIDE_TOKEN", "fake-token")
218213
.arg("api")

cli/tests/test_auth.rs

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use std::{
99
path::Path,
1010
};
1111

12-
use assert_cmd::Command;
1312
use chrono::{DateTime, Utc};
1413
use expectorate::assert_contents;
1514
use httpmock::{Method::POST, Mock, MockServer};
@@ -147,8 +146,7 @@ fn test_auth_login_first() {
147146
// Make sure we know how to make non-existent directories.
148147
let config_dir = temp_dir_path.join(".config").join("oxide");
149148

150-
let cmd = Command::cargo_bin("oxide")
151-
.unwrap()
149+
let cmd = assert_cmd::cargo::cargo_bin_cmd!("oxide")
152150
.env("RUST_BACKTRACE", "1")
153151
.arg("--config-dir")
154152
.arg(config_dir.as_os_str())
@@ -234,8 +232,7 @@ fn test_auth_login_existing_default() {
234232
write_first_config(temp_dir_path);
235233
assert_mode(&temp_dir_path.join("config.toml"), 0o644);
236234

237-
let cmd = Command::cargo_bin("oxide")
238-
.unwrap()
235+
let cmd = assert_cmd::cargo::cargo_bin_cmd!("oxide")
239236
.env("RUST_BACKTRACE", "1")
240237
.arg("--profile")
241238
.arg("crystal-palace")
@@ -281,8 +278,7 @@ fn test_auth_login_existing_no_default() {
281278
write_first_creds(temp_dir_path);
282279
assert_mode(&temp_dir_path.join("credentials.toml"), 0o600);
283280

284-
let cmd = Command::cargo_bin("oxide")
285-
.unwrap()
281+
let cmd = assert_cmd::cargo::cargo_bin_cmd!("oxide")
286282
.env("RUST_BACKTRACE", "1")
287283
.arg("--config-dir")
288284
.arg(temp_dir_path.as_os_str())
@@ -340,8 +336,7 @@ fn test_auth_credentials_permissions() {
340336
assert_mode(&cred_path, 0o644);
341337

342338
// Validate authenticated credentials
343-
let cmd = Command::cargo_bin("oxide")
344-
.unwrap()
339+
let cmd = assert_cmd::cargo::cargo_bin_cmd!("oxide")
345340
.arg("--config-dir")
346341
.arg(temp_dir_path.as_os_str())
347342
.arg("auth")
@@ -370,8 +365,7 @@ fn test_auth_login_double() {
370365
let temp_dir = tempfile::tempdir().unwrap();
371366
let temp_dir_path = temp_dir.path();
372367

373-
Command::cargo_bin("oxide")
374-
.unwrap()
368+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
375369
.env("RUST_BACKTRACE", "1")
376370
.arg("--config-dir")
377371
.arg(temp_dir_path.as_os_str())
@@ -382,8 +376,7 @@ fn test_auth_login_double() {
382376
.arg(server.url(""))
383377
.assert()
384378
.success();
385-
let cmd = Command::cargo_bin("oxide")
386-
.unwrap()
379+
let cmd = assert_cmd::cargo::cargo_bin_cmd!("oxide")
387380
.env("RUST_BACKTRACE", "1")
388381
.arg("--config-dir")
389382
.arg(temp_dir_path.as_os_str())
@@ -493,8 +486,7 @@ fn test_cmd_auth_status() {
493486
});
494487

495488
// Validate authenticated credentials
496-
let cmd = Command::cargo_bin("oxide")
497-
.unwrap()
489+
let cmd = assert_cmd::cargo::cargo_bin_cmd!("oxide")
498490
.arg("--config-dir")
499491
.arg(temp_dir.path().as_os_str())
500492
.arg("auth")
@@ -515,8 +507,7 @@ fn test_cmd_auth_status() {
515507
);
516508

517509
// Validate empty `credentials.toml` does not error.
518-
Command::cargo_bin("oxide")
519-
.unwrap()
510+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
520511
.arg("--config-dir")
521512
.arg(empty_creds_dir.path().as_os_str())
522513
.arg("auth")
@@ -564,8 +555,7 @@ fn test_cmd_auth_status_env() {
564555
);
565556

566557
// Validate authenticated credentials
567-
Command::cargo_bin("oxide")
568-
.unwrap()
558+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
569559
.arg("auth")
570560
.arg("status")
571561
.env("OXIDE_HOST", server.url(""))
@@ -578,8 +568,7 @@ fn test_cmd_auth_status_env() {
578568
));
579569

580570
// OXIDE_PROFILE also works, uses creds file
581-
Command::cargo_bin("oxide")
582-
.unwrap()
571+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
583572
.env("OXIDE_PROFILE", "funky-town")
584573
.arg("--config-dir")
585574
.arg(temp_dir.path().as_os_str())
@@ -593,8 +582,7 @@ fn test_cmd_auth_status_env() {
593582
));
594583

595584
// OXIDE_HOST conflicts with OXIDE_PROFILE
596-
Command::cargo_bin("oxide")
597-
.unwrap()
585+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
598586
.env("OXIDE_HOST", server.url(""))
599587
.env("OXIDE_TOKEN", "oxide-token-good")
600588
.env("OXIDE_PROFILE", "ignored")
@@ -622,8 +610,7 @@ fn test_cmd_auth_status_env() {
622610
});
623611

624612
// Try invalid credentials.
625-
Command::cargo_bin("oxide")
626-
.unwrap()
613+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
627614
.arg("auth")
628615
.arg("status")
629616
.env("OXIDE_HOST", server.url(""))
@@ -655,8 +642,7 @@ fn test_cmd_auth_debug_logging() {
655642
});
656643
});
657644

658-
let cmd = Command::cargo_bin("oxide")
659-
.unwrap()
645+
let cmd = assert_cmd::cargo::cargo_bin_cmd!("oxide")
660646
.arg("--debug")
661647
.arg("auth")
662648
.arg("status")
@@ -696,3 +682,26 @@ fn test_cmd_auth_debug_logging() {
696682

697683
oxide_mock.assert();
698684
}
685+
686+
#[test]
687+
fn test_cmd_auth_login() {
688+
use predicates::str;
689+
690+
let temp_dir = tempfile::tempdir().unwrap();
691+
692+
let bad_url = "sys.oxide.invalid";
693+
694+
// Validate connection error details are printed
695+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
696+
.arg("--config-dir")
697+
.arg(temp_dir.path().as_os_str())
698+
.arg("auth")
699+
.arg("login")
700+
.arg("--host")
701+
.arg(bad_url)
702+
.assert()
703+
.failure()
704+
.stderr(str::starts_with(
705+
"Request failed: client error: error sending request",
706+
));
707+
}

cli/tests/test_bundles.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// Copyright 2025 Oxide Computer Company
66

7-
use assert_cmd::Command;
87
use httpmock::MockServer;
98
use oxide_httpmock::MockServerExt;
109

@@ -52,8 +51,7 @@ fn test_bundle_download_ranges() {
5251
.body([1; 1024]);
5352
});
5453

55-
Command::cargo_bin("oxide")
56-
.unwrap()
54+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
5755
.env("RUST_BACKTRACE", "1")
5856
.env("OXIDE_HOST", server.url(""))
5957
.env("OXIDE_TOKEN", "fake-token")
@@ -116,8 +114,7 @@ fn test_bundle_download_range_too_large_response() {
116114
.body([0; 4096]);
117115
});
118116

119-
Command::cargo_bin("oxide")
120-
.unwrap()
117+
assert_cmd::cargo::cargo_bin_cmd!("oxide")
121118
.env("RUST_BACKTRACE", "1")
122119
.env("OXIDE_HOST", server.url(""))
123120
.env("OXIDE_TOKEN", "fake-token")

0 commit comments

Comments
 (0)