Skip to content

Commit a7a358c

Browse files
committed
chore: run tests only in non-windows environments
1 parent ccee7a4 commit a7a358c

File tree

2 files changed

+67
-60
lines changed

2 files changed

+67
-60
lines changed

tests/add_integration_tests.rs

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,56 @@
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;
46

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();
1416

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:
1820
--otpuri
1921
--label <LABEL>
2022
2123
Usage: cotp add --otpuri --label <LABEL>
2224
2325
For more information, try '--help'.
2426
",
25-
));
26-
}
27+
));
28+
}
2729

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
4345
AA
4446
",
45-
)
46-
.assert();
47+
)
48+
.assert();
4749

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+
}
5356
}

tests/cli_integration_tests.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
use assert_cmd::Command;
2-
use predicates::str::{is_empty, is_match, starts_with};
1+
#[cfg(not(target_os = "windows"))] // TODO, Integration tests currently does not work on Windows
2+
mod cli_integration_test {
33

4-
#[test]
5-
fn test_version_subcommand() {
6-
// Arrange / Act
7-
let assertion = Command::cargo_bin("cotp")
8-
.unwrap()
9-
.arg("--version")
10-
.assert();
4+
use assert_cmd::Command;
5+
use predicates::str::{is_empty, is_match, starts_with};
116

12-
// Assert
13-
assertion
14-
.success()
15-
.stdout(is_match("^cotp \\d+\\.\\d+\\.\\d+-DEBUG-.+").unwrap())
16-
.stderr(is_empty());
17-
}
7+
#[test]
8+
fn test_version_subcommand() {
9+
// Arrange / Act
10+
let assertion = Command::cargo_bin("cotp")
11+
.unwrap()
12+
.arg("--version")
13+
.assert();
14+
15+
// Assert
16+
assertion
17+
.success()
18+
.stdout(is_match("^cotp \\d+\\.\\d+\\.\\d+-DEBUG-.+").unwrap())
19+
.stderr(is_empty());
20+
}
1821

19-
#[test]
20-
fn test_help_subcommand() {
21-
// Arrange / Act
22-
let assertion = Command::cargo_bin("cotp").unwrap().arg("--help").assert();
22+
#[test]
23+
fn test_help_subcommand() {
24+
// Arrange / Act
25+
let assertion = Command::cargo_bin("cotp").unwrap().arg("--help").assert();
2326

24-
// Assert
25-
assertion
27+
// Assert
28+
assertion
2629
.success()
2730
.stdout(starts_with(
2831
"Trustworthy, encrypted, command-line TOTP/HOTP authenticator app with import functionality.
2932
3033
Usage: cotp [OPTIONS] [COMMAND]",
3134
))
3235
.stderr(is_empty());
36+
}
3337
}

0 commit comments

Comments
 (0)