test: Use insta, closes #57
Use insta for UI tests, adds snapshots of UI layout
This commit is contained in:
@@ -136,6 +136,7 @@ pub fn draw(
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod tests {
|
||||
use insta::assert_snapshot;
|
||||
use ratatui::style::{Color, Modifier};
|
||||
|
||||
use crate::{
|
||||
@@ -144,8 +145,8 @@ mod tests {
|
||||
ui::{
|
||||
FrameData,
|
||||
draw_blocks::tests::{
|
||||
BORDER_CHARS, COLOR_ORANGE, COLOR_RX, COLOR_TX, TuiTestSetup, expected_to_vec,
|
||||
get_result, test_setup,
|
||||
BORDER_CHARS, COLOR_ORANGE, COLOR_RX, COLOR_TX, TuiTestSetup, get_result,
|
||||
test_setup,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -153,19 +154,9 @@ mod tests {
|
||||
#[test]
|
||||
/// No containers, panel unselected, then selected, border color changes correctly
|
||||
fn test_draw_blocks_containers_none() {
|
||||
let (w, h) = (25, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(40, 6, true, true);
|
||||
setup.app_data.lock().containers = StatefulList::new(vec![]);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers ───────────╮",
|
||||
"│ no containers running │",
|
||||
"│ │",
|
||||
"│ │",
|
||||
"│ │",
|
||||
"╰───────────────────────╯",
|
||||
];
|
||||
|
||||
setup.gui_state.lock().next_panel();
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
@@ -184,10 +175,9 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
for (_, result_row) in get_result(&setup) {
|
||||
for result_cell in result_row {
|
||||
if BORDER_CHARS.contains(&result_cell.symbol()) {
|
||||
assert_eq!(result_cell.fg, Color::Gray);
|
||||
}
|
||||
@@ -211,10 +201,8 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
for (_, result_row) in get_result(&setup) {
|
||||
for result_cell in result_row {
|
||||
if BORDER_CHARS.contains(&result_cell.symbol()) {
|
||||
assert_eq!(result_cell.fg, Color::LightCyan);
|
||||
}
|
||||
@@ -225,17 +213,8 @@ mod tests {
|
||||
#[test]
|
||||
/// Containers panel drawn, selected line is bold, border is blue
|
||||
fn test_draw_blocks_containers_selected_bold() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ✓ running Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
|
||||
setup
|
||||
@@ -252,11 +231,9 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
|
||||
if BORDER_CHARS.contains(&result_cell.symbol()) {
|
||||
assert_eq!(result_cell.fg, Color::LightCyan);
|
||||
}
|
||||
@@ -294,11 +271,8 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
|
||||
for (_, result_row) in get_result(&setup) {
|
||||
for result_cell in result_row {
|
||||
if BORDER_CHARS.contains(&result_cell.symbol()) {
|
||||
assert_eq!(result_cell.fg, Color::Gray);
|
||||
}
|
||||
@@ -309,17 +283,8 @@ mod tests {
|
||||
#[test]
|
||||
/// Columns on all rows are coloured correctly
|
||||
fn test_draw_blocks_containers_colors() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ✓ running Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
|
||||
@@ -337,12 +302,10 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
|
||||
match (row_index, result_cell_index) {
|
||||
//border
|
||||
(0 | 5, _) | (1..=4, 0 | 129) => {
|
||||
@@ -373,21 +336,12 @@ mod tests {
|
||||
#[test]
|
||||
/// Long container + image name is truncated correctly
|
||||
fn test_draw_blocks_containers_long_name_image() {
|
||||
let (w, h) = (170, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(170, 6, true, true);
|
||||
setup.app_data.lock().containers.items[0].name =
|
||||
ContainerName::from("a_long_container_name_for_the_purposes_of_this_test");
|
||||
setup.app_data.lock().containers.items[0].image =
|
||||
ContainerImage::from("a_long_image_name_for_the_purposes_of_this_test");
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ a_long_container_name_for_the… ॥ paused Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 a_long_image_name_for_the_pur… 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
setup.app_data.lock().containers.items[0].state = State::Paused;
|
||||
@@ -405,22 +359,14 @@ mod tests {
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
}
|
||||
}
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
}
|
||||
|
||||
// Check that the correct colour is applied to the state/status/cpu/memory section
|
||||
fn check_expected(expected: [&str; 6], w: u16, _h: u16, setup: &TuiTestSetup, color: Color) {
|
||||
for (row_index, result_row) in get_result(setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
|
||||
fn check_colour(setup: &TuiTestSetup, color: Color) {
|
||||
for (row_index, result_row) in get_result(setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
match (row_index, result_cell_index) {
|
||||
// border
|
||||
(0 | 5, _) | (1..=4, 0 | 129) => {
|
||||
@@ -455,17 +401,8 @@ mod tests {
|
||||
#[test]
|
||||
/// When container is paused, correct colors displayed
|
||||
fn test_draw_blocks_containers_paused() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ॥ paused Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
setup.app_data.lock().containers.items[0].state = State::Paused;
|
||||
@@ -484,23 +421,14 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
check_expected(expected, w, h, &setup, Color::Yellow);
|
||||
check_colour(&setup, Color::Yellow);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// When container is dead, correct colors displayed
|
||||
fn test_draw_blocks_containers_dead() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ✖ dead Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
setup.app_data.lock().containers.items[0].state = State::Dead;
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
@@ -519,23 +447,15 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
check_expected(expected, w, h, &setup, Color::Red);
|
||||
check_colour(&setup, Color::Red);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// When container is exited, correct colors displayed
|
||||
fn test_draw_blocks_containers_exited() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ✖ exited Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
setup.app_data.lock().containers.items[0].state = State::Exited;
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
@@ -554,22 +474,14 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
check_expected(expected, w, h, &setup, Color::Red);
|
||||
check_colour(&setup, Color::Red);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
}
|
||||
#[test]
|
||||
/// When container is paused, correct colors displayed
|
||||
fn test_draw_blocks_containers_removing() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 removing Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
setup.app_data.lock().containers.items[0].state = State::Removing;
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
@@ -588,23 +500,15 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
check_expected(expected, w, h, &setup, Color::LightRed);
|
||||
check_colour(&setup, Color::LightRed);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// When container state is restarting, correct colors displayed
|
||||
fn test_draw_blocks_containers_restarting() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ↻ restarting Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
setup.app_data.lock().containers.items[0].state = State::Restarting;
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
@@ -623,11 +527,10 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
match (row_index, result_cell_index) {
|
||||
// border
|
||||
(0 | 5, _) | (1..=4, 0 | 129) => {
|
||||
@@ -664,21 +567,12 @@ mod tests {
|
||||
#[test]
|
||||
/// When container state is unhealthy, correct colors displayed
|
||||
fn test_draw_blocks_containers_unhealthy() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let status = ContainerStatus::from("Up 1 hour (unhealthy)".to_owned());
|
||||
setup.app_data.lock().containers.items[0].state = State::from(("running", &status));
|
||||
setup.app_data.lock().containers.items[0].status = status;
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ! running Up 1 hour (unhealthy) 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
|
||||
@@ -696,10 +590,10 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
match (row_index, result_cell_index) {
|
||||
// border
|
||||
(0 | 5, _) | (1..=4, 0 | 129) => {
|
||||
@@ -734,17 +628,8 @@ mod tests {
|
||||
#[test]
|
||||
/// When container state is unknown, correct colors displayed
|
||||
fn test_draw_blocks_containers_unknown() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ? unknown Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
setup.app_data.lock().containers.items[0].state = State::Unknown;
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let colors = setup.app_data.lock().config.app_colors;
|
||||
@@ -763,23 +648,15 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
check_expected(expected, w, h, &setup, Color::Red);
|
||||
check_colour(&setup, Color::Red);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// Custom colors applied correctly
|
||||
fn test_draw_blocks_containers_custom_colors() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ✓ running Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
let mut colors = AppColors::new();
|
||||
colors.borders.selected = Color::Green;
|
||||
@@ -804,11 +681,9 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
// The highlight symbol can't correctly be colored
|
||||
if (row_index, result_cell_index) != (1, 2) {
|
||||
assert_eq!(result_cell.bg, Color::Black);
|
||||
@@ -843,17 +718,8 @@ mod tests {
|
||||
#[test]
|
||||
/// Make sure that the state has the correctly color applied to it
|
||||
fn test_draw_blocks_containers_custom_colors_state_healthy() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ✓ running Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
|
||||
// Healthy
|
||||
@@ -874,11 +740,9 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
if let (1..=3, 18..=70) = (row_index, result_cell_index) {
|
||||
assert_eq!(result_cell.fg, Color::Magenta);
|
||||
}
|
||||
@@ -888,18 +752,8 @@ mod tests {
|
||||
#[test]
|
||||
/// Make sure that the state has the correctly color applied to it
|
||||
fn test_draw_blocks_containers_custom_colors_state_unhealthy() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
// Unhealthy
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ! running Up 1 hour (unhealthy) 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
|
||||
let mut colors = AppColors::new();
|
||||
@@ -922,11 +776,9 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
if let (1, 18..=70) = (row_index, result_cell_index) {
|
||||
assert_eq!(result_cell.fg, Color::Red);
|
||||
}
|
||||
@@ -937,16 +789,7 @@ mod tests {
|
||||
#[test]
|
||||
/// Make sure that the state has the correctly color applied to it
|
||||
fn test_draw_blocks_containers_custom_colors_state_dead() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ✖ dead Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
|
||||
@@ -967,12 +810,9 @@ mod tests {
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
if let (1, 18..=70) = (row_index, result_cell_index) {
|
||||
assert_eq!(result_cell.fg, Color::Magenta);
|
||||
}
|
||||
@@ -983,16 +823,7 @@ mod tests {
|
||||
#[test]
|
||||
/// Make sure that the state has the correctly color applied to it
|
||||
fn test_draw_blocks_containers_custom_colors_state_exited() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ✖ exited Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
|
||||
@@ -1014,11 +845,10 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
if let (1, 18..=70) = (row_index, result_cell_index) {
|
||||
assert_eq!(result_cell.fg, Color::Gray);
|
||||
}
|
||||
@@ -1029,16 +859,7 @@ mod tests {
|
||||
#[test]
|
||||
/// Make sure that the state has the correctly color applied to it
|
||||
fn test_draw_blocks_containers_custom_colors_state_paused() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ॥ paused Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
|
||||
@@ -1059,12 +880,10 @@ mod tests {
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
if let (1, 18..=70) = (row_index, result_cell_index) {
|
||||
assert_eq!(result_cell.fg, Color::Cyan);
|
||||
}
|
||||
@@ -1075,16 +894,7 @@ mod tests {
|
||||
#[test]
|
||||
/// Make sure that the state has the correctly color applied to it
|
||||
fn test_draw_blocks_containers_custom_colors_state_removing() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 removing Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
|
||||
@@ -1105,12 +915,10 @@ mod tests {
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
if let (1, 18..=70) = (row_index, result_cell_index) {
|
||||
assert_eq!(result_cell.fg, Color::White);
|
||||
}
|
||||
@@ -1121,16 +929,7 @@ mod tests {
|
||||
#[test]
|
||||
/// Make sure that the state has the correctly color applied to it
|
||||
fn test_draw_blocks_containers_custom_colors_state_restarting() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ↻ restarting Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
|
||||
@@ -1152,11 +951,10 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
if let (1, 18..=70) = (row_index, result_cell_index) {
|
||||
assert_eq!(result_cell.fg, Color::LightYellow);
|
||||
}
|
||||
@@ -1167,16 +965,7 @@ mod tests {
|
||||
#[test]
|
||||
/// Make sure that the state has the correctly color applied to it
|
||||
fn test_draw_blocks_containers_custom_colors_state_unknown() {
|
||||
let (w, h) = (130, 6);
|
||||
let mut setup = test_setup(w, h, true, true);
|
||||
let expected = [
|
||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||
"│⚪ container_1 ? unknown Up 1 hour 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||
];
|
||||
let mut setup = test_setup(130, 6, true, true);
|
||||
|
||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||
|
||||
@@ -1198,11 +987,10 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for (row_index, result_row) in get_result(&setup, w) {
|
||||
let expected_row = expected_to_vec(&expected, row_index);
|
||||
assert_snapshot!(setup.terminal.backend());
|
||||
|
||||
for (row_index, result_row) in get_result(&setup) {
|
||||
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
|
||||
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
|
||||
if let (1, 18..=70) = (row_index, result_cell_index) {
|
||||
assert_eq!(result_cell.fg, COLOR_ORANGE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user