mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-17 20:10:51 +01:00
add regression tests
This way we don't regress on accident again in the future.
This commit is contained in:
parent
fc852f8be6
commit
7ef9fe3454
1 changed files with 32 additions and 0 deletions
|
@ -37,6 +37,7 @@ use crate::{
|
||||||
|
|
||||||
use super::pdu::PduBuilder;
|
use super::pdu::PduBuilder;
|
||||||
|
|
||||||
|
#[cfg_attr(test, derive(Debug))]
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "@conduit:server.name:", version = env!("CARGO_PKG_VERSION"))]
|
#[command(name = "@conduit:server.name:", version = env!("CARGO_PKG_VERSION"))]
|
||||||
enum AdminCommand {
|
enum AdminCommand {
|
||||||
|
@ -1160,3 +1161,34 @@ impl Service {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn get_help_short() {
|
||||||
|
get_help_inner("-h");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn get_help_long() {
|
||||||
|
get_help_inner("--help");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn get_help_subcommand() {
|
||||||
|
get_help_inner("help");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_help_inner(input: &str) {
|
||||||
|
let error = AdminCommand::try_parse_from(["argv[0] doesn't matter", input])
|
||||||
|
.unwrap_err()
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
// Search for a handful of keywords that suggest the help printed properly
|
||||||
|
assert!(error.contains("Usage:"));
|
||||||
|
assert!(error.contains("Commands:"));
|
||||||
|
assert!(error.contains("Options:"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue