diff options
Diffstat (limited to 'rust/semi-structured-logs/tests/semi-structured-logs.rs')
-rw-r--r-- | rust/semi-structured-logs/tests/semi-structured-logs.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/rust/semi-structured-logs/tests/semi-structured-logs.rs b/rust/semi-structured-logs/tests/semi-structured-logs.rs new file mode 100644 index 0000000..fc45208 --- /dev/null +++ b/rust/semi-structured-logs/tests/semi-structured-logs.rs @@ -0,0 +1,47 @@ +use semi_structured_logs::{error, info, log, warn, LogLevel}; + +#[test] +fn emits_info() { + assert_eq!(info("Timezone changed"), "[INFO]: Timezone changed"); +} + +#[test] +fn emits_warning() { + assert_eq!(warn("Timezone not set"), "[WARNING]: Timezone not set"); +} + +#[test] +fn emits_error() { + assert_eq!(error("Disk full"), "[ERROR]: Disk full"); +} + +#[test] +fn log_emits_info() { + assert_eq!( + log(LogLevel::Info, "Timezone changed"), + "[INFO]: Timezone changed" + ); +} + +#[test] +fn log_emits_warning() { + assert_eq!( + log(LogLevel::Warning, "Timezone not set"), + "[WARNING]: Timezone not set" + ); +} + +#[test] +fn log_emits_error() { + assert_eq!(log(LogLevel::Error, "Disk full"), "[ERROR]: Disk full"); +} + +#[test] +#[cfg(feature = "add-a-variant")] +fn add_a_variant() { + // this test won't even compile until the enum is complete, which is why it is feature-gated. + assert_eq!( + log(LogLevel::Debug, "reached line 123"), + "[DEBUG]: reached line 123", + ); +} |