| 878 |
878 |
|
Some(0)
|
| 879 |
879 |
|
}
|
| 880 |
880 |
|
|
| 881 |
|
- |
#[cfg(test)]
|
| 882 |
|
- |
mod inspection_tests {
|
| 883 |
|
- |
use super::*;
|
| 884 |
|
- |
|
| 885 |
|
- |
#[test]
|
| 886 |
|
- |
fn version_flags_are_recognised() {
|
| 887 |
|
- |
assert_eq!(inspection_request(["--version"]), Some(Inspection::Version));
|
| 888 |
|
- |
assert_eq!(inspection_request(["-V"]), Some(Inspection::Version));
|
| 889 |
|
- |
}
|
| 890 |
|
- |
|
| 891 |
|
- |
#[test]
|
| 892 |
|
- |
fn help_flags_are_recognised() {
|
| 893 |
|
- |
assert_eq!(inspection_request(["--help"]), Some(Inspection::Help));
|
| 894 |
|
- |
assert_eq!(inspection_request(["-h"]), Some(Inspection::Help));
|
| 895 |
|
- |
}
|
| 896 |
|
- |
|
| 897 |
|
- |
#[test]
|
| 898 |
|
- |
fn boot_arguments_are_not_inspection_requests() {
|
| 899 |
|
- |
assert_eq!(inspection_request(Vec::<String>::new()), None);
|
| 900 |
|
- |
assert_eq!(inspection_request(["--seed-examples"]), None);
|
| 901 |
|
- |
}
|
| 902 |
|
- |
|
| 903 |
|
- |
#[test]
|
| 904 |
|
- |
fn the_first_inspection_flag_wins() {
|
| 905 |
|
- |
assert_eq!(
|
| 906 |
|
- |
inspection_request(["--seed-examples", "--version", "--help"]),
|
| 907 |
|
- |
Some(Inspection::Version)
|
| 908 |
|
- |
);
|
| 909 |
|
- |
}
|
| 910 |
|
- |
|
| 911 |
|
- |
#[test]
|
| 912 |
|
- |
fn version_line_carries_the_crate_version() {
|
| 913 |
|
- |
assert!(version_line().starts_with(&format!("makenotwork {}", env!("CARGO_PKG_VERSION"))));
|
| 914 |
|
- |
}
|
| 915 |
|
- |
}
|
| 916 |
|
- |
|
| 917 |
881 |
|
/// Wait for SIGINT (Ctrl-C) or SIGTERM, then return to trigger graceful shutdown.
|
| 918 |
882 |
|
/// In-flight requests get up to `SHUTDOWN_REQUEST_DRAIN_SECS` to complete, then
|
| 919 |
883 |
|
/// the post-serve drains get `SHUTDOWN_POOL_DRAIN_SECS`; the hard-exit timer
|
| 952 |
916 |
|
std::process::exit(1);
|
| 953 |
917 |
|
});
|
| 954 |
918 |
|
}
|
|
919 |
+ |
|
|
920 |
+ |
#[cfg(test)]
|
|
921 |
+ |
mod inspection_tests {
|
|
922 |
+ |
use super::*;
|
|
923 |
+ |
|
|
924 |
+ |
#[test]
|
|
925 |
+ |
fn version_flags_are_recognised() {
|
|
926 |
+ |
assert_eq!(inspection_request(["--version"]), Some(Inspection::Version));
|
|
927 |
+ |
assert_eq!(inspection_request(["-V"]), Some(Inspection::Version));
|
|
928 |
+ |
}
|
|
929 |
+ |
|
|
930 |
+ |
#[test]
|
|
931 |
+ |
fn help_flags_are_recognised() {
|
|
932 |
+ |
assert_eq!(inspection_request(["--help"]), Some(Inspection::Help));
|
|
933 |
+ |
assert_eq!(inspection_request(["-h"]), Some(Inspection::Help));
|
|
934 |
+ |
}
|
|
935 |
+ |
|
|
936 |
+ |
#[test]
|
|
937 |
+ |
fn boot_arguments_are_not_inspection_requests() {
|
|
938 |
+ |
assert_eq!(inspection_request(Vec::<String>::new()), None);
|
|
939 |
+ |
assert_eq!(inspection_request(["--seed-examples"]), None);
|
|
940 |
+ |
}
|
|
941 |
+ |
|
|
942 |
+ |
#[test]
|
|
943 |
+ |
fn the_first_inspection_flag_wins() {
|
|
944 |
+ |
assert_eq!(
|
|
945 |
+ |
inspection_request(["--seed-examples", "--version", "--help"]),
|
|
946 |
+ |
Some(Inspection::Version)
|
|
947 |
+ |
);
|
|
948 |
+ |
}
|
|
949 |
+ |
|
|
950 |
+ |
#[test]
|
|
951 |
+ |
fn version_line_carries_the_crate_version() {
|
|
952 |
+ |
assert!(version_line().starts_with(&format!("makenotwork {}", env!("CARGO_PKG_VERSION"))));
|
|
953 |
+ |
}
|
|
954 |
+ |
}
|