|
1 | | -use assert_cmd::Command; |
2 | | -use predicates::{ord::eq, str::is_empty}; |
3 | | -use test_case::test_case; |
| 1 | +#[cfg(not(target_os = "windows"))] // TODO, Integration tests currently does not work on Windows |
| 2 | +mod add_integration_tests { |
| 3 | + use assert_cmd::Command; |
| 4 | + use predicates::{ord::eq, str::is_empty}; |
| 5 | + use test_case::test_case; |
4 | 6 |
|
5 | | -#[test] |
6 | | -fn add_without_label_should_fail() { |
7 | | - // Arrange / Act |
8 | | - let assertion = Command::cargo_bin("cotp") |
9 | | - .unwrap() |
10 | | - .arg("--database-path") |
11 | | - .arg("test_samples/cli_integration_test/empty_database") |
12 | | - .arg("add") |
13 | | - .assert(); |
| 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(); |
14 | 16 |
|
15 | | - // Assert |
16 | | - assertion.failure().code(2).stdout(is_empty()).stderr(eq( |
17 | | - "error: the following required arguments were not provided: |
| 17 | + // Assert |
| 18 | + assertion.failure().code(2).stdout(is_empty()).stderr(eq( |
| 19 | + "error: the following required arguments were not provided: |
18 | 20 | --otpuri |
19 | 21 | --label <LABEL> |
20 | 22 |
|
21 | 23 | Usage: cotp add --otpuri --label <LABEL> |
22 | 24 |
|
23 | 25 | For more information, try '--help'. |
24 | 26 | ", |
25 | | - )); |
26 | | -} |
| 27 | + )); |
| 28 | + } |
27 | 29 |
|
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 |
| 30 | + #[test_case("-l" ; "Short subcommand")] |
| 31 | + #[test_case("--label" ; "Long subcommand")] |
| 32 | + fn add_with_label_should_work(label_arg: &str) { |
| 33 | + // Arrange / Act |
| 34 | + let assertion = Command::cargo_bin("cotp") |
| 35 | + .unwrap() |
| 36 | + .arg("--password-stdin") |
| 37 | + .arg("--database-path") |
| 38 | + .arg("test_samples/cli_integration_test/empty_database") |
| 39 | + .arg("add") |
| 40 | + .arg(label_arg) |
| 41 | + .arg("test") |
| 42 | + .arg("--secret-stdin") |
| 43 | + .write_stdin( |
| 44 | + "12345678 |
43 | 45 | AA |
44 | 46 | ", |
45 | | - ) |
46 | | - .assert(); |
| 47 | + ) |
| 48 | + .assert(); |
47 | 49 |
|
48 | | - // Assert |
49 | | - assertion |
50 | | - .success() |
51 | | - .stderr(is_empty()) |
52 | | - .stdout(eq("Modifications have been persisted\n")); |
| 50 | + // Assert |
| 51 | + assertion |
| 52 | + .success() |
| 53 | + .stderr(is_empty()) |
| 54 | + .stdout(eq("Modifications have been persisted\n")); |
| 55 | + } |
53 | 56 | } |
0 commit comments