1
0
mirror of https://github.com/pcvolkmer/checkbar.git synced 2025-04-19 11:06:50 +00:00

Add tests for check result display

This commit is contained in:
Paul-Christian Volkmer 2023-01-15 03:57:15 +01:00
parent a76e3d8035
commit 8d312f86b5

View File

@ -62,3 +62,47 @@ pub trait HttpBasedChecker {
fn get_check_config(&self) -> &CheckConfig; fn get_check_config(&self) -> &CheckConfig;
} }
#[cfg(test)]
mod tests {
use crate::checker::*;
#[test]
fn test_should_display_check_result_up() {
let check_result = CheckResult {
name: "test".to_string(),
state: CheckState::Up,
};
assert_eq!(
check_result.to_string(),
r##"{"color":"#00FF00","full_text":"test","name":"test","separator_block_width":16}"##
)
}
#[test]
fn test_should_display_check_result_warn() {
let check_result = CheckResult {
name: "test".to_string(),
state: CheckState::Warn,
};
assert_eq!(
check_result.to_string(),
r##"{"color":"#FFFF00","full_text":"test","name":"test","separator_block_width":16}"##
)
}
#[test]
fn test_should_display_check_result_down() {
let check_result = CheckResult {
name: "test".to_string(),
state: CheckState::Down,
};
assert_eq!(
check_result.to_string(),
r##"{"color":"#FF0000","full_text":"test","name":"test","separator_block_width":16}"##
)
}
}