Skip to content

Commit

Permalink
feat: add integration tests
Browse files Browse the repository at this point in the history
- Add `assert_cmd` to `dev-dependencies` in `Cargo.toml`
  • Loading branch information
amiyzku committed Dec 20, 2023
1 parent cde9da1 commit 990e238
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
97 changes: 97 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ clap = { version = "4.4.11", features = ["derive", "env"] }
regex = "1.10.2"
serde = { version = "1.0.193", features = ["derive"] }
thiserror = "1.0.51"

[dev-dependencies]
assert_cmd = "2.0.12"
48 changes: 48 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
struct Setup {
cmd: assert_cmd::Command,
email: String,
password: String,
}

fn setup() -> Setup {
let cmd = assert_cmd::Command::cargo_bin("jobcan").expect("Failed to find jobcan binary");
let email = std::env::var("JOBCAN_EMAIL").expect("JOBCAN_EMAIL is not set");
let password = std::env::var("JOBCAN_PASSWORD").expect("JOBCAN_PASSWORD is not set");
Setup {
cmd,
email,
password,
}
}

#[tokio::test]
async fn process_of_getting_work_status_correctly() {
let Setup {
mut cmd,
email,
password,
} = setup();
cmd.arg("status")
.arg("--email")
.arg(email)
.arg("--password")
.arg(password)
.assert()
.success();
}

#[tokio::test]
async fn process_of_getting_group_list_correctly() {
let Setup {
mut cmd,
email,
password,
} = setup();
cmd.arg("list-groups")
.arg("--email")
.arg(email)
.arg("--password")
.arg(password)
.assert()
.success();
}

0 comments on commit 990e238

Please sign in to comment.