Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quambene committed Apr 3, 2024
1 parent 1d4fd64 commit 8f8b7f1
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,62 @@ pub fn app() -> Command {
]),
)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_send_args_subject_content() {
let args = vec![
"pigeon",
"send",
"[email protected]",
"[email protected]",
"--subject",
"Test subject",
"--content",
"This is a test message (plaintext).",
];
let app = app();
let matches = app.get_matches_from(args);
let subcommand_matches = matches.subcommand_matches("send");
assert!(subcommand_matches.is_some());
}

#[test]
fn test_send_args_text_file_html_file() {
let args = vec![
"pigeon",
"send",
"[email protected]",
"[email protected]",
"--subject",
"Test subject",
"--text-file",
"./test_data/message.txt",
"--html-file",
"./test_data/message.html",
];
let app = app();
let matches = app.get_matches_from(args);
let subcommand_matches = matches.subcommand_matches("send");
assert!(subcommand_matches.is_some());
}

#[test]
fn test_send_args_message_file() {
let args = vec![
"pigeon",
"send",
"[email protected]",
"[email protected]",
"--message-file",
"./test_data/message.yaml",
];
let app = app();
let matches = app.get_matches_from(args);
let subcommand_matches = matches.subcommand_matches("send");
assert!(subcommand_matches.is_some());
}
}

0 comments on commit 8f8b7f1

Please sign in to comment.