Skip to content

Commit 22d1415

Browse files
committed
test: add subcommand integration tests
1 parent 4a9c3e6 commit 22d1415

File tree

4 files changed

+139
-0
lines changed

4 files changed

+139
-0
lines changed

Cargo.lock

Lines changed: 109 additions & 0 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ globset = "0.4.16"
5858

5959
[dev-dependencies]
6060
assert_cmd = "2.0.17"
61+
assert_fs = "1.1.3"
6162
predicates = "3.1.3"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":1,"nonce":"MRFGJOdHjt9wrSbqlWHrwmMGENmjjCMh","salt":"eQkRyDUTaaWNVy/+S/CXIw==","cipher":"tBtvz2AOp7XPUJGSLkm+Ss+exKFjd0eA1UWd58nM/I45P7VmdK6/28c9vw=="}

tests/add_integration_tests.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use assert_cmd::Command;
2+
use predicates::{
3+
ord::eq,
4+
str::{is_empty, is_match, starts_with},
5+
};
6+
7+
#[test]
8+
fn add_without_label_should_fail() {
9+
// Arrange / Act
10+
let assertion = Command::cargo_bin("cotp")
11+
.unwrap()
12+
.arg("--database-path")
13+
.arg("test_samples/cli_integration_test/empty_database")
14+
.arg("add")
15+
.assert();
16+
17+
// Assert
18+
assertion.failure().code(2).stdout(is_empty()).stderr(eq(
19+
"error: the following required arguments were not provided:
20+
--otpuri
21+
--label <LABEL>
22+
23+
Usage: cotp add --otpuri --label <LABEL>
24+
25+
For more information, try '--help'.
26+
",
27+
));
28+
}

0 commit comments

Comments
 (0)