Skip to content

Commit ccee7a4

Browse files
committed
test: add more add integration tests
1 parent c8a4d11 commit ccee7a4

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

Cargo.lock

Lines changed: 34 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
@@ -60,3 +60,4 @@ globset = "0.4.16"
6060
assert_cmd = "2.0.17"
6161
assert_fs = "1.1.3"
6262
predicates = "3.1.3"
63+
test-case = "3.3.1"

tests/add_integration_tests.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use assert_cmd::Command;
2-
use predicates::{
3-
ord::eq,
4-
str::{is_empty, is_match, starts_with},
5-
};
2+
use predicates::{ord::eq, str::is_empty};
3+
use test_case::test_case;
64

75
#[test]
86
fn add_without_label_should_fail() {
@@ -26,3 +24,30 @@ For more information, try '--help'.
2624
",
2725
));
2826
}
27+
28+
#[test_case("-l" ; "Short subcommand")]
29+
#[test_case("--label" ; "Long subcommand")]
30+
fn add_with_label_should_work(label_arg: &str) {
31+
// Arrange / Act
32+
let assertion = Command::cargo_bin("cotp")
33+
.unwrap()
34+
.arg("--password-stdin")
35+
.arg("--database-path")
36+
.arg("test_samples/cli_integration_test/empty_database")
37+
.arg("add")
38+
.arg(label_arg)
39+
.arg("test")
40+
.arg("--secret-stdin")
41+
.write_stdin(
42+
"12345678
43+
AA
44+
",
45+
)
46+
.assert();
47+
48+
// Assert
49+
assertion
50+
.success()
51+
.stderr(is_empty())
52+
.stdout(eq("Modifications have been persisted\n"));
53+
}

0 commit comments

Comments
 (0)