tests: fix logs tests

This commit is contained in:
Jack Wills
2024-12-03 21:29:49 +00:00
parent 1a8dab654a
commit 9b22f5da18
+12 -16
View File
@@ -1879,21 +1879,18 @@ mod tests {
#[test] #[test]
/// No logs, panel unselected, then selected, border color changes correctly /// No logs, panel unselected, then selected, border color changes correctly
fn test_draw_blocks_logs_none() { fn test_draw_blocks_logs_none() {
let (w, h) = (25, 6); let (w, h) = (35, 6);
let mut setup = test_setup(w, h, true, true); let mut setup = test_setup(w, h, true, true);
setup.app_data.lock().containers = StatefulList::new(vec![]);
let expected = [ let expected = [
"╭ Logs ─────────────────╮", "╭ Logs - container_1 - image_1 ───╮",
"│ no logs found │", "│ no logs found │",
"│ │", "│ │",
"│ │", "│ │",
"│ │", "│ │",
"╰───────────────────────╯", "╰─────────────────────────────────",
]; ];
let _fd = FrameData::from((setup.app_data.lock(), setup.gui_state.lock()));
setup setup
.terminal .terminal
.draw(|f| { .draw(|f| {
@@ -1925,7 +1922,6 @@ mod tests {
let expected_row = expected_to_vec(&expected, row_index); let expected_row = expected_to_vec(&expected, row_index);
for (result_cell_index, result_cell) in result_row.iter().enumerate() { for (result_cell_index, result_cell) in result_row.iter().enumerate() {
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]); assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
if BORDER_CHARS.contains(&result_cell.symbol()) { if BORDER_CHARS.contains(&result_cell.symbol()) {
assert_eq!(result_cell.fg, Color::LightCyan); assert_eq!(result_cell.fg, Color::LightCyan);
} }
@@ -2001,7 +1997,7 @@ mod tests {
#[test] #[test]
/// Logs correct displayed, changing log state also draws correctly /// Logs correct displayed, changing log state also draws correctly
fn test_draw_blocks_logs_some() { fn test_draw_blocks_logs_some() {
let (w, h) = (25, 6); let (w, h) = (36, 6);
let mut setup = test_setup(w, h, true, true); let mut setup = test_setup(w, h, true, true);
insert_logs(&setup); insert_logs(&setup);
@@ -2014,12 +2010,12 @@ mod tests {
}) })
.unwrap(); .unwrap();
let expected = [ let expected = [
"╭ Logs 3/3 - container_1╮", "╭ Logs 3/3 - container_1 - image_1 ",
"│ line 1 │", "│ line 1 │",
"│ line 2 │", "│ line 2 │",
"│▶ line 3 │", "│▶ line 3 │",
"│ │", "│ │",
"╰───────────────────────╯", "╰──────────────────────────────────",
]; ];
for (row_index, result_row) in get_result(&setup, w) { for (row_index, result_row) in get_result(&setup, w) {
@@ -2028,7 +2024,7 @@ mod tests {
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]); assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
assert_eq!(result_cell.fg, Color::Reset); assert_eq!(result_cell.fg, Color::Reset);
if row_index == 3 && (1..=23).contains(&result_cell_index) { if row_index == 3 && (1..=34).contains(&result_cell_index) {
assert_eq!(result_cell.modifier, Modifier::BOLD); assert_eq!(result_cell.modifier, Modifier::BOLD);
} else { } else {
assert!(result_cell.modifier.is_empty()); assert!(result_cell.modifier.is_empty());
@@ -2038,22 +2034,22 @@ mod tests {
// Change selected log line // Change selected log line
setup.app_data.lock().log_previous(); setup.app_data.lock().log_previous();
_ = FrameData::from((setup.app_data.lock(), setup.gui_state.lock())); let fd = FrameData::from((setup.app_data.lock(), setup.gui_state.lock()));
setup setup
.terminal .terminal
.draw(|f| { .draw(|f| {
super::logs(&setup.app_data, setup.area, f, &setup.fd, &setup.gui_state); super::logs(&setup.app_data, setup.area, f, &fd, &setup.gui_state);
}) })
.unwrap(); .unwrap();
let expected = [ let expected = [
"╭ Logs 2/3 - container_1╮", "╭ Logs 2/3 - container_1 - image_1 ",
"│ line 1 │", "│ line 1 │",
"│▶ line 2 │", "│▶ line 2 │",
"│ line 3 │", "│ line 3 │",
"│ │", "│ │",
"╰───────────────────────╯", "╰──────────────────────────────────",
]; ];
for (row_index, result_row) in get_result(&setup, w) { for (row_index, result_row) in get_result(&setup, w) {
let expected_row = expected_to_vec(&expected, row_index); let expected_row = expected_to_vec(&expected, row_index);
@@ -2061,7 +2057,7 @@ mod tests {
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]); assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
assert_eq!(result_cell.fg, Color::Reset); assert_eq!(result_cell.fg, Color::Reset);
if row_index == 2 && (1..=23).contains(&result_cell_index) { if row_index == 2 && (1..=34).contains(&result_cell_index) {
assert_eq!(result_cell.modifier, Modifier::BOLD); assert_eq!(result_cell.modifier, Modifier::BOLD);
} else { } else {
assert!(result_cell.modifier.is_empty()); assert!(result_cell.modifier.is_empty());