-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
491425b
commit 454e14d
Showing
8 changed files
with
239 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::sync::{LockResult, Mutex, MutexGuard}; | ||
|
||
use assert_cmd::Command; | ||
use predicates::prelude::*; | ||
|
||
/// We can only have a single webdriver session. | ||
static WEBDRIVER_MUTEX: Mutex<()> = Mutex::new(()); | ||
|
||
#[test] | ||
fn test_help() { | ||
let mut cmd = cmd(); | ||
cmd.arg("--help").assert().success(); | ||
} | ||
|
||
#[test] | ||
fn test_list_folders() { | ||
let _guard = webdriver_mutex(); | ||
let mut cmd = cmd(); | ||
cmd.arg("--screenshot-on-failure") | ||
.arg("--screenshot-path=test_list_folders.png") | ||
.arg("-vv") | ||
.arg("list-folders") | ||
.assert() | ||
.success() | ||
.stdout(predicate::str::contains( | ||
["Inbox", "Drafts", "Sent", "Trash", "Archive", "Spam"].join("\n"), | ||
)); | ||
} | ||
|
||
#[test] | ||
fn test_export() { | ||
let _guard = webdriver_mutex(); | ||
let mut cmd = cmd(); | ||
cmd.arg("--screenshot-on-failure") | ||
.arg("--screenshot-path=test_export.png") | ||
.arg("-vv") | ||
.arg("export") | ||
.arg("--folder=Archive") | ||
.assert() | ||
.success(); | ||
} | ||
|
||
fn cmd() -> Command { | ||
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap() | ||
} | ||
|
||
fn webdriver_mutex() -> MutexGuard<'static, ()> { | ||
match WEBDRIVER_MUTEX.lock() { | ||
LockResult::Ok(guard) => guard, | ||
// poisoned locks are OK | ||
LockResult::Err(e) => e.into_inner(), | ||
} | ||
} |