test: Use insta, closes #57

Use insta for UI tests, adds snapshots of UI layout
This commit is contained in:
Jack Wills
2025-04-16 11:16:45 +00:00
parent 8f959c5408
commit 9362d7b481
126 changed files with 2059 additions and 1773 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
"--security-opt",
"seccomp=unconfined"
],
"postCreateCommand": "cargo install cross typos-cli cargo-expand",
"postCreateCommand": "cargo install cross typos-cli cargo-expand cargo-insta",
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
Generated
+64
View File
@@ -294,6 +294,18 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "console"
version = "0.15.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8"
dependencies = [
"encode_unicode",
"libc",
"once_cell",
"windows-sys 0.59.0",
]
[[package]]
name = "convert_case"
version = "0.7.1"
@@ -465,6 +477,12 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]]
name = "encode_unicode"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
[[package]]
name = "equivalent"
version = "1.0.2"
@@ -925,6 +943,19 @@ version = "2.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
[[package]]
name = "insta"
version = "1.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50259abbaa67d11d2bcafc7ba1d094ed7a0c70e3ce893f0d0997f73558cb3084"
dependencies = [
"console",
"linked-hash-map",
"once_cell",
"pin-project",
"similar",
]
[[package]]
name = "instability"
version = "0.3.7"
@@ -1033,6 +1064,12 @@ dependencies = [
"libc",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
@@ -1172,6 +1209,7 @@ dependencies = [
"crossterm 0.29.0",
"directories",
"futures-util",
"insta",
"jiff",
"parking_lot",
"ratatui",
@@ -1221,6 +1259,26 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "pin-project"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "pin-project-lite"
version = "0.2.16"
@@ -1545,6 +1603,12 @@ dependencies = [
"libc",
]
[[package]]
name = "similar"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
[[package]]
name = "slab"
version = "0.4.9"
+3
View File
@@ -52,3 +52,6 @@ codegen-units = 1
panic = 'abort'
strip = true
debug = false
[dev-dependencies]
insta = "1.42.2"
+2 -1
View File
@@ -35,7 +35,8 @@ impl ContainerId {
}
/// Only return first 8 chars of id, is usually more than enough for uniqueness
/// TODO container id is a hex string, so can assume that 0..=8 will always return a 8 char ascii &str - need to update tests to use real ids, or atleast strings of the correct-ish length
/// TODO container id is a hex string, so can assume that 0..=8 will always return a 8 char ascii &str
/// need to update tests to use real ids, or atleast strings of the correct-ish length
pub fn get_short(&self) -> String {
self.0.chars().take(8).collect::<String>()
}
+2 -2
View File
@@ -420,8 +420,8 @@ impl AppData {
}
/// Get all the ContainerItems
/// Thnk this allow block can be removed with the 1.87 release of Clippy
#[allow(clippy::missing_const_for_fn)]
/// Thnk this allow block can be removed with the 1.87 release of Clippy
#[allow(clippy::missing_const_for_fn)]
pub fn get_container_items(&self) -> &[ContainerItem] {
&self.containers.items
}
+2 -4
View File
@@ -232,11 +232,9 @@ mod tests {
#[test]
/// Test various timezones get parsed correctly
fn test_config_parse_timezone() {
assert!(super::Config::parse_timezone(None).is_none());
// Timezone with no offset just return None
for i in ["Europe/London", "Africa/Accra"] {
assert!(super::Config::parse_timezone(Some(i.to_owned())).is_none());
for i in [None, Some("UTC".to_owned())] {
assert!(super::Config::parse_timezone(i).is_none());
}
let expected = Some(TimeZone::get("Asia/Tokyo").unwrap());
+21 -47
View File
@@ -167,6 +167,7 @@ pub fn draw(area: Rect, colors: AppColors, f: &mut Frame, fd: &FrameData) {
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use insta::assert_snapshot;
use ratatui::style::{Color, Modifier};
use crate::{
@@ -174,14 +175,12 @@ mod tests {
config::AppColors,
ui::{
FrameData,
draw_blocks::tests::{
COLOR_ORANGE, expected_to_vec, get_result, insert_chart_data, test_setup,
},
draw_blocks::tests::{COLOR_ORANGE, get_result, insert_chart_data, test_setup},
},
};
/// CPU and Memory charts used in multiple tests, based on data from above insert_chart_data()
const EXPECTED: [&str; 10] = [
const _EXPECTED: [&str; 10] = [
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮",
"│10.00%│ • ││100.00 kB│ •• │",
"│ │ •• ││ │ •• │",
@@ -236,8 +235,7 @@ mod tests {
#[test]
/// When status is Running, but not data, charts drawn without dots etc, colours correct
fn test_draw_blocks_charts_running_none() {
let (w, h) = (80, 10);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(80, 10, true, true);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
setup
@@ -246,25 +244,10 @@ mod tests {
super::draw(setup.area, setup.app_data.lock().config.app_colors, f, &fd);
})
.unwrap();
assert_snapshot!(setup.terminal.backend());
let expected = [
"╭───────────── cpu 00.00% ─────────────╮╭─────────── memory 0.00 kB ───────────╮",
"│00.00%│ ││0.00 kB│ │",
"│ │ ││ │ │",
"│ │ ││ │ │",
"│ │ ││ │ │",
"│ │ ││ │ │",
"│ │ ││ │ │",
"│ │ ││ │ │",
"│ │ ││ │ │",
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯",
];
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]);
match (row_index, result_cell_index) {
(0, 14..=25 | 52..=67) => {
assert_eq!(result_cell.fg, Color::Green);
@@ -290,8 +273,7 @@ mod tests {
#[test]
/// When status is Running, charts correctly drawn
fn test_draw_blocks_charts_running_some() {
let (w, h) = (80, 10);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(80, 10, true, true);
insert_chart_data(&setup);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
@@ -303,11 +285,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) {
(0, 14..=25 | 51..=67) => {
assert_eq!(result_cell.fg, Color::Green);
@@ -341,8 +322,7 @@ mod tests {
#[test]
/// Whens status paused, some text is now Yellow
fn test_draw_blocks_charts_paused() {
let (w, h) = (80, 10);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(80, 10, true, true);
insert_chart_data(&setup);
setup.app_data.lock().containers.items[0].state = State::Paused;
@@ -355,11 +335,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) {
(0, 14..=25 | 51..=67) | (1, 1..=6 | 41..=49) => {
assert_eq!(result_cell.fg, Color::Yellow);
@@ -389,8 +368,7 @@ mod tests {
#[test]
/// When dead, text is red
fn test_draw_blocks_charts_dead() {
let (w, h) = (80, 10);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(80, 10, true, true);
insert_chart_data(&setup);
setup.app_data.lock().containers.items[0].state = State::Dead;
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
@@ -401,12 +379,9 @@ mod tests {
super::draw(setup.area, setup.app_data.lock().config.app_colors, f, &fd);
})
.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) {
(0, 14..=25 | 51..=67) | (1, 1..=6 | 41..=49) => {
assert_eq!(result_cell.fg, Color::Red);
@@ -452,8 +427,7 @@ mod tests {
colors.chart_memory.points = Color::Black;
colors.chart_memory.y_axis = Color::Blue;
let (w, h) = (80, 10);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(80, 10, true, true);
insert_chart_data(&setup);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
@@ -465,10 +439,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]);
assert_eq!(result_cell.bg, Color::White);
match (row_index, result_cell_index) {
+83 -95
View File
@@ -55,6 +55,7 @@ pub fn draw(
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use insta::assert_snapshot;
use ratatui::style::{Color, Modifier};
use crate::{
@@ -62,16 +63,16 @@ mod tests {
tests::gen_container_summary,
ui::{
FrameData,
draw_blocks::tests::{BORDER_CHARS, expected_to_vec, get_result, test_setup},
draw_blocks::tests::{BORDER_CHARS, get_result, test_setup},
},
};
// cusomt border colors
#[test]
/// Test that when DockerCommands are available, they are drawn correctly, dependant on container state
/// In this case, no commands are drawn
fn test_draw_blocks_commands_none() {
let (w, h) = (12, 6);
let mut setup = test_setup(w, h, false, false);
let mut setup = test_setup(12, 6, false, false);
let colors = setup.app_data.lock().config.app_colors;
setup
@@ -88,28 +89,14 @@ mod tests {
})
.unwrap();
let expected = [
"╭──────────╮",
"│ │",
"│ │",
"│ │",
"│ │",
"╰──────────╯",
];
for (row_index, row) in get_result(&setup, w) {
let expected_row = expected_to_vec(&expected, row_index);
for (cell_index, cell) in row.iter().enumerate() {
assert_eq!(cell.symbol(), expected_row[cell_index]);
}
}
assert_snapshot!(setup.terminal.backend());
}
#[test]
/// Test that when DockerCommands are available, they are drawn correctly, dependant on container state
/// In this test, container is running
fn test_draw_blocks_commands_some() {
let (w, h) = (12, 6);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(12, 6, true, true);
let colors = setup.app_data.lock().config.app_colors;
setup
@@ -126,19 +113,10 @@ mod tests {
})
.unwrap();
let expected = [
"╭──────────╮",
"│▶ pause │",
"│ restart │",
"│ stop │",
"│ delete │",
"╰──────────╯",
];
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]);
assert_eq!(result_cell.bg, Color::Reset);
match (row_index, result_cell_index) {
// Borders & delete
@@ -163,22 +141,36 @@ mod tests {
}
}
}
// Change the controls state
}
#[test]
/// Test that when DockerCommands are available, they are drawn correctly, dependant on container state
/// In this test, container is paused
fn test_draw_blocks_commands_some_paused() {
let mut setup = test_setup(12, 6, true, true);
let colors = setup.app_data.lock().config.app_colors;
setup
.terminal
.draw(|f| {
super::draw(
&setup.app_data,
setup.area,
colors,
f,
&setup.fd,
&setup.gui_state,
);
})
.unwrap();
// Set the container state to paused
setup
.app_data
.lock()
.update_containers(vec![gen_container_summary(1, "paused")]);
setup.app_data.lock().docker_controls_next();
let expected = [
"╭──────────╮",
"│ resume │",
"│▶ stop │",
"│ delete │",
"│ │",
"╰──────────╯",
];
setup
.terminal
.draw(|f| {
@@ -193,10 +185,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]);
assert_eq!(result_cell.bg, Color::Reset);
match (row_index, result_cell_index) {
// resume
@@ -222,16 +214,7 @@ mod tests {
#[test]
/// When control panel is selected, the border is blue, if not then white, selected text is highlighted
fn test_draw_blocks_commands_panel_selected_color() {
let (w, h) = (12, 6);
let mut setup = test_setup(w, h, true, true);
let expected = [
"╭──────────╮",
"│▶ pause │",
"│ restart │",
"│ stop │",
"│ delete │",
"╰──────────╯",
];
let mut setup = test_setup(12, 6, true, true);
let colors = setup.app_data.lock().config.app_colors;
// Unselected, has a grey border
setup
@@ -248,10 +231,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);
}
@@ -275,10 +257,8 @@ mod tests {
})
.unwrap();
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 row_index == 0
|| row_index == 5
|| result_cell_index == 0
@@ -296,10 +276,9 @@ mod tests {
}
#[test]
/// Custom colors are rendered correctlty
fn test_draw_blocks_commands_custom_colors() {
let (w, h) = (12, 6);
let mut setup = test_setup(w, h, true, true);
/// Custom colors are rendered correctly
fn test_draw_blocks_commands_custom_colors_running() {
let mut setup = test_setup(12, 6, true, true);
let mut colors = AppColors::new();
colors.commands.background = Color::White;
colors.commands.pause = Color::Black;
@@ -323,19 +302,9 @@ mod tests {
})
.unwrap();
let expected = [
"╭──────────╮",
"│▶ pause │",
"│ restart │",
"│ stop │",
"│ delete │",
"╰──────────╯",
];
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]);
assert_eq!(result_cell.bg, Color::White);
match (row_index, result_cell_index) {
// pause
@@ -358,21 +327,19 @@ mod tests {
}
}
}
// Change the controls state
setup
.app_data
.lock()
.update_containers(vec![gen_container_summary(1, "paused")]);
setup.app_data.lock().docker_controls_next();
let expected = [
"╭──────────╮",
"│ resume │",
"│▶ stop │",
"│ delete │",
"│ │",
"╰──────────╯",
];
}
#[test]
/// Custom colors are rendered correctly
fn test_draw_blocks_commands_custom_colors_paused() {
let mut setup = test_setup(12, 6, true, true);
let mut colors = AppColors::new();
colors.commands.background = Color::White;
colors.commands.pause = Color::Black;
colors.commands.restart = Color::Green;
colors.commands.stop = Color::Blue;
colors.commands.delete = Color::Magenta;
colors.commands.resume = Color::Yellow;
colors.commands.start = Color::Cyan;
setup
.terminal
@@ -388,10 +355,31 @@ mod tests {
})
.unwrap();
for (row_index, result_row) in get_result(&setup, w) {
let expected_row = expected_to_vec(&expected, row_index);
// Set the controls state
setup
.app_data
.lock()
.update_containers(vec![gen_container_summary(1, "paused")]);
setup.app_data.lock().docker_controls_next();
setup
.terminal
.draw(|f| {
super::draw(
&setup.app_data,
setup.area,
colors,
f,
&setup.fd,
&setup.gui_state,
);
})
.unwrap();
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]);
assert_eq!(result_cell.bg, Color::White);
match (row_index, result_cell_index) {
+72 -284
View File
@@ -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);
}
+27 -119
View File
@@ -128,32 +128,20 @@ pub fn draw(
#[allow(clippy::unwrap_used)]
mod tests {
use crossterm::event::KeyCode;
use insta::assert_snapshot;
use ratatui::style::{Color, Modifier};
use crate::{
app_data::ContainerName,
config::{AppColors, Keymap},
ui::draw_blocks::tests::{expected_to_vec, get_result, test_setup},
ui::draw_blocks::tests::{get_result, test_setup},
};
#[test]
/// Delete container popup is drawn correctly
fn test_draw_blocks_delete() {
let (w, h) = (82, 10);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(82, 10, true, true);
let expected = [
" ",
" ╭──────────────────────── Confirm Delete ────────────────────────╮ ",
" │ │ ",
" │ Are you sure you want to delete container: container_1 │ ",
" │ │ ",
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ ",
" │ │ ( n ) no │ │ ( y ) yes │ │ ",
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ ",
" ╰────────────────────────────────────────────────────────────────╯ ",
" ",
];
let colors = setup.app_data.lock().config.app_colors;
let keymap = &setup.app_data.lock().config.keymap;
@@ -170,11 +158,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]);
match (row_index, result_cell_index) {
(0 | 9, _) | (1..=8, 0..=7 | 74..=81) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -197,23 +183,10 @@ mod tests {
#[test]
/// Delete container popup is drawn correctly
fn test_draw_blocks_delete_long_name() {
let (w, h) = (106, 10);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(106, 10, true, true);
let name = ContainerName::from("container_1_container_1_container_1");
setup.app_data.lock().containers.items[0].name = name.clone();
let expected = [
" ",
" ╭──────────────────────────────────── Confirm Delete ────────────────────────────────────╮ ",
" │ │ ",
" │ Are you sure you want to delete container: container_1_container_1_container_1 │ ",
" │ │ ",
" │ ╭──────────────────────────────╮ ╭─────────────────────────────╮ │ ",
" │ │ ( n ) no │ │ ( y ) yes │ │ ",
" │ ╰──────────────────────────────╯ ╰─────────────────────────────╯ │ ",
" ╰────────────────────────────────────────────────────────────────────────────────────────╯ ",
" ",
];
let colors = setup.app_data.lock().config.app_colors;
let keymap = &setup.app_data.lock().config.keymap;
@@ -223,12 +196,9 @@ mod tests {
super::draw(colors, f, &setup.gui_state, keymap, &name);
})
.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) {
(0 | 9, _) | (1..=8, 0..=7 | 98..=106) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -251,21 +221,7 @@ mod tests {
#[test]
/// Custom colors applied correctly to delete popup
fn test_draw_blocks_delete_custom_colors() {
let (w, h) = (82, 10);
let mut setup = test_setup(w, h, true, true);
let expected = [
" ",
" ╭──────────────────────── Confirm Delete ────────────────────────╮ ",
" │ │ ",
" │ Are you sure you want to delete container: container_1 │ ",
" │ │ ",
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ ",
" │ │ ( n ) no │ │ ( y ) yes │ │ ",
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ ",
" ╰────────────────────────────────────────────────────────────────╯ ",
" ",
];
let mut setup = test_setup(82, 10, true, true);
let mut colors = AppColors::new();
colors.popup_delete.background = Color::Black;
colors.popup_delete.text = Color::Yellow;
@@ -284,11 +240,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) {
(0 | 9, _) | (1..=8, 0..=7 | 74..=81) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -310,22 +265,8 @@ mod tests {
#[test]
/// Custom keymap, with multiple definitions for each button, applied correctly to delete popup
#[allow(clippy::too_many_lines)]
fn test_draw_blocks_delete_custom_keymap() {
let (w, h) = (82, 10);
let mut setup = test_setup(w, h, true, true);
let expected = [
" ",
" ╭──────────────────────── Confirm Delete ────────────────────────╮ ",
" │ │ ",
" │ Are you sure you want to delete container: container_1 │ ",
" │ │ ",
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ ",
" │ │ ( End ) no │ │ ( F10 ) yes │ │ ",
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ ",
" ╰────────────────────────────────────────────────────────────────╯ ",
" ",
];
fn test_draw_blocks_delete_custom_keymap_one_definition() {
let mut setup = test_setup(82, 10, true, true);
let mut keymap = Keymap::new();
keymap.delete_confirm = (KeyCode::F(10), None);
keymap.delete_deny = (KeyCode::End, None);
@@ -341,25 +282,12 @@ 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]);
}
}
let expected = [
" ",
" ╭──────────────────────── Confirm Delete ────────────────────────╮ ",
" │ │ ",
" │ Are you sure you want to delete container: container_1 │ ",
" │ │ ",
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ ",
" │ │ ( End | Up ) no │ │ ( F10 | L ) yes │ │ ",
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ ",
" ╰────────────────────────────────────────────────────────────────╯ ",
" ",
];
assert_snapshot!(setup.terminal.backend());
}
#[test]
/// Custom keymap, with multiple definitions for each button, applied correctly to delete popup
fn test_draw_blocks_delete_custom_keymap_two_definition() {
let mut setup = test_setup(82, 10, true, true);
let mut keymap = Keymap::new();
keymap.delete_confirm = (KeyCode::F(10), Some(KeyCode::Char('L')));
keymap.delete_deny = (KeyCode::End, Some(KeyCode::Up));
@@ -375,26 +303,12 @@ 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]);
}
}
let expected = [
" ",
" ╭──────────────────────── Confirm Delete ────────────────────────╮ ",
" │ │ ",
" │ Are you sure you want to delete container: container_1 │ ",
" │ │ ",
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ ",
" │ │ ( End | Up ) no │ │ ( F10 ) yes │ │ ",
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ ",
" ╰────────────────────────────────────────────────────────────────╯ ",
" ",
];
assert_snapshot!(setup.terminal.backend());
}
#[test]
/// Custom keymap, with multiple definitions for each button, applied correctly to delete popup
fn test_draw_blocks_delete_custom_keymap_one_two_definition() {
let mut setup = test_setup(82, 10, true, true);
let mut keymap = Keymap::new();
keymap.delete_confirm = (KeyCode::F(10), None);
keymap.delete_deny = (KeyCode::End, Some(KeyCode::Up));
@@ -410,12 +324,6 @@ 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());
}
}
+41 -144
View File
@@ -14,6 +14,9 @@ use crate::{
use super::popup;
const SUFFIX_CLEAR: &str = "clear error";
const SUFFIX_QUIT: &str = "quit oxker";
/// Draw an error popup over whole screen
pub fn draw(
colors: AppColors,
@@ -36,24 +39,21 @@ pub fn draw(
seconds.unwrap_or(5)
)
} else {
let clear_suffix = "clear error";
let clear_text = if keymap.clear == Keymap::new().clear {
format!("( {} ) {clear_suffix}", keymap.clear.0)
format!("( {} ) {SUFFIX_CLEAR}", keymap.clear.0)
} else if let Some(secondary) = keymap.clear.1 {
format!(" ( {} | {secondary} ) {clear_suffix}", keymap.clear.0)
format!(" ( {} | {secondary} ) {SUFFIX_CLEAR}", keymap.clear.0)
} else {
format!(" ( {} ) {clear_suffix}", keymap.clear.0)
format!(" ( {} ) {SUFFIX_CLEAR}", keymap.clear.0)
};
let quit_suffix = "quit oxker";
let quit_text = if keymap.quit == Keymap::new().quit {
format!("( {} ) {quit_suffix}", keymap.quit.0)
format!("( {} ) {SUFFIX_QUIT}", keymap.quit.0)
} else if let Some(secondary) = keymap.quit.1 {
format!(" ( {} | {secondary} ) {quit_suffix}", keymap.quit.0)
format!(" ( {} | {secondary} ) {SUFFIX_QUIT}", keymap.quit.0)
} else {
format!(" ( {} ) {quit_suffix}", keymap.quit.0)
format!(" ( {} ) {SUFFIX_QUIT}", keymap.quit.0)
};
format!("\n\n{clear_text}\n\n{quit_text}")
};
@@ -94,21 +94,19 @@ pub fn draw(
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::VERSION;
use crate::{
app_error::AppError,
config::{AppColors, Keymap},
ui::draw_blocks::tests::{expected_to_vec, get_result, test_setup},
ui::draw_blocks::tests::{get_result, test_setup},
};
use crossterm::event::KeyCode;
use insta::assert_snapshot;
use ratatui::style::Color;
#[test]
/// Test that the error popup is centered, red background, white border, white text, and displays the correct text
fn test_draw_blocks_error_docker_connect_error() {
let (w, h) = (46, 9);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(46, 9, true, true);
setup
.terminal
@@ -122,34 +120,15 @@ mod tests {
);
})
.unwrap();
let version_row = format!(" │ oxker::v{VERSION} closing in 04 seconds │ ");
let expected = [
" ",
" ╭───────────────── Error ──────────────────╮ ",
" │ │ ",
" │ Unable to access docker daemon │ ",
" │ │ ",
version_row.as_str(),
" │ │ ",
" ╰──────────────────────────────────────────╯ ",
" ",
];
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) {
(0 | 8, _) | (1..=7, 0 | 45) => {
assert_eq!(result_cell.bg, Color::Reset);
assert_eq!(result_cell.fg, Color::Reset);
}
_ => {
assert_eq!(result_cell.bg, Color::Red);
assert_eq!(result_cell.fg, Color::White);
}
if let (0 | 8, _) = (row_index, result_cell_index) {
assert_eq!(result_cell.bg, Color::Reset);
assert_eq!(result_cell.fg, Color::Reset);
} else {
assert_eq!(result_cell.bg, Color::Red);
assert_eq!(result_cell.fg, Color::White);
}
}
}
@@ -158,8 +137,7 @@ mod tests {
#[test]
/// Test that the clearable error popup is centered, red background, white border, white text, and displays the correct text
fn test_draw_blocks_error_clearable_error() {
let (w, h) = (39, 11);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(39, 11, true, true);
setup
.terminal
@@ -174,25 +152,10 @@ mod tests {
})
.unwrap();
let expected = [
" ",
" ╭────────────── Error ──────────────╮ ",
" │ │ ",
" │ Unable to exec into container │ ",
" │ │ ",
" │ ( c ) clear error │ ",
" │ │ ",
" │ ( q ) quit oxker │ ",
" │ │ ",
" ╰───────────────────────────────────╯ ",
" ",
];
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]);
match (row_index, result_cell_index) {
(0 | 10, _) | (1..=9, 0 | 38) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -211,8 +174,7 @@ mod tests {
#[test]
/// Custom colors applied to the error popup correctly
fn test_draw_blocks_error_custom_colors() {
let (w, h) = (39, 11);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(39, 11, true, true);
let mut colors = AppColors::new();
colors.popup_error.background = Color::Yellow;
@@ -225,25 +187,10 @@ mod tests {
})
.unwrap();
let expected = [
" ",
" ╭────────────── Error ──────────────╮ ",
" │ │ ",
" │ Unable to exec into container │ ",
" │ │ ",
" │ ( c ) clear error │ ",
" │ │ ",
" │ ( q ) quit oxker │ ",
" │ │ ",
" ╰───────────────────────────────────╯ ",
" ",
];
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]);
match (row_index, result_cell_index) {
(0 | 10, _) | (1..=9, 0 | 38) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -260,10 +207,9 @@ mod tests {
}
#[test]
/// Custom keymap applied correct with both 1 and 2 definitions
/// Custom keymap applied correctly
fn test_draw_blocks_error_custom_keymap() {
let (w, h) = (39, 11);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(39, 11, true, true);
let mut keymap = Keymap::new();
keymap.clear = (KeyCode::BackTab, None);
@@ -275,27 +221,12 @@ mod tests {
super::draw(AppColors::new(), &AppError::DockerExec, f, &keymap, None);
})
.unwrap();
let expected = [
" ",
" ╭────────────── Error ──────────────╮ ",
" │ │ ",
" │ Unable to exec into container │ ",
" │ │ ",
" │ ( Back Tab ) clear error │ ",
" │ │ ",
" │ ( F4 ) quit oxker │ ",
" │ │ ",
" ╰───────────────────────────────────╯ ",
" ",
];
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());
}
#[test]
/// Custom keymap applied with two definitions for each option
fn test_draw_blocks_error_custom_keymap_two_definitions() {
let mut setup = test_setup(39, 11, true, true);
let mut keymap = Keymap::new();
keymap.clear = (KeyCode::BackTab, Some(KeyCode::Char('m')));
@@ -307,27 +238,13 @@ mod tests {
super::draw(AppColors::new(), &AppError::DockerExec, f, &keymap, None);
})
.unwrap();
assert_snapshot!(setup.terminal.backend());
}
let expected = [
" ",
" ╭────────────── Error ──────────────╮ ",
" │ │ ",
" │ Unable to exec into container │ ",
" │ │ ",
" │ ( Back Tab | m ) clear error │ ",
" │ │ ",
" │ ( F4 | End ) quit oxker │ ",
" │ │ ",
" ╰───────────────────────────────────╯ ",
" ",
];
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]);
}
}
#[test]
/// Custom keymap applied correctly, with 1 definition for the first option, and 2 definitions for the other
fn test_draw_blocks_error_custom_keymap_one_two_definitions() {
let mut setup = test_setup(39, 11, true, true);
let mut keymap = Keymap::new();
keymap.quit = (KeyCode::F(4), Some(KeyCode::End));
@@ -338,26 +255,6 @@ mod tests {
super::draw(AppColors::new(), &AppError::DockerExec, f, &keymap, None);
})
.unwrap();
let expected = [
" ",
" ╭────────────── Error ──────────────╮ ",
" │ │ ",
" │ Unable to exec into container │ ",
" │ │ ",
" │ ( c ) clear error │ ",
" │ │ ",
" │ ( F4 | End ) quit oxker │ ",
" │ │ ",
" ╰───────────────────────────────────╯ ",
" ",
];
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());
}
}
+41 -37
View File
@@ -71,23 +71,22 @@ pub fn draw(area: Rect, colors: AppColors, frame: &mut Frame, fd: &FrameData) {
#[allow(clippy::unwrap_used)]
mod tests {
use insta::assert_snapshot;
use ratatui::style::{Color, Modifier};
use crate::{
config::AppColors,
ui::{
FrameData,
draw_blocks::tests::{expected_to_vec, get_result, test_setup},
draw_blocks::tests::{get_result, test_setup},
},
};
#[test]
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
/// Filter row is drawn correctly & colors are correct
/// Colours change when filter_by option is changed
fn test_draw_blocks_filter_row() {
let (w, h) = (140, 1);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(140, 1, true, true);
setup
.gui_state
@@ -100,15 +99,10 @@ mod tests {
})
.unwrap();
let expected = [
" Esc clear ← by → Name Image Status All term: ",
];
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 (_, 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 result_cell_index {
0..=4 | 12..=19 => {
assert_eq!(result_cell.bg, Color::Magenta);
@@ -134,6 +128,22 @@ mod tests {
}
}
}
}
#[test]
/// Colours change when filter_by option is changed
fn test_draw_blocks_filter_row_text() {
let mut setup = test_setup(140, 1, true, true);
setup
.gui_state
.lock()
.status_push(crate::ui::Status::Filter);
setup
.terminal
.draw(|f| {
super::draw(setup.area, AppColors::new(), f, &setup.fd);
})
.unwrap();
// Test when char added to search term
setup.app_data.lock().filter_term_push('c');
@@ -147,15 +157,10 @@ mod tests {
})
.unwrap();
let expected = [
" Esc clear ← by → Name Image Status All term: cd ",
];
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 (_, 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 result_cell_index {
0..=4 | 12..=19 => {
assert_eq!(result_cell.bg, Color::Magenta);
@@ -181,35 +186,39 @@ mod tests {
}
}
}
}
// Test when filter_by changes
#[test]
/// Colours change when filter_by option is changed
fn test_draw_blocks_filter_row_filter_by() {
let mut setup = test_setup(140, 1, true, true);
setup
.gui_state
.lock()
.status_push(crate::ui::Status::Filter);
setup.app_data.lock().filter_by_next();
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
setup
.terminal
.draw(|f| {
super::draw(setup.area, AppColors::new(), f, &fd);
super::draw(setup.area, AppColors::new(), f, &setup.fd);
})
.unwrap();
let expected = [
" Esc clear ← by → Name Image Status All term: cd ",
];
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 (_, 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 result_cell_index {
0..=4 | 12..=19 => {
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(result_cell.fg, Color::Black);
}
5..=11 | 21..=26 | 34..=46 | 54..=55 => {
5..=11 | 27..=46 => {
assert_eq!(result_cell.bg, Color::Reset);
assert_eq!(result_cell.fg, Color::Gray);
}
27..=33 => {
21..=26 => {
assert_eq!(result_cell.bg, Color::Gray);
assert_eq!(result_cell.fg, Color::Black);
}
@@ -230,8 +239,7 @@ mod tests {
#[test]
/// Make sure custom colors are applied
fn test_draw_blocks_filter_row_custom_colors() {
let (w, h) = (140, 1);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(140, 1, true, true);
setup
.gui_state
@@ -256,14 +264,10 @@ mod tests {
})
.unwrap();
let expected = [
" Esc clear ← by → Name Image Status All term: cd ",
];
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 (_, 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 result_cell_index {
0..=4 | 12..=19 => {
assert_eq!(result_cell.bg, Color::Blue);
+215 -258
View File
@@ -222,6 +222,7 @@ mod tests {
use std::ops::RangeInclusive;
use crossterm::event::KeyCode;
use insta::assert_snapshot;
use ratatui::style::Color;
use uuid::Uuid;
@@ -230,22 +231,17 @@ mod tests {
config::{AppColors, Keymap},
ui::{
FrameData, Status,
draw_blocks::tests::{expected_to_vec, get_result, test_setup},
draw_blocks::tests::{TuiTestSetup, get_result, test_setup},
},
};
#[test]
/// Heading back only has show/exit help when no containers, correctly coloured
fn test_draw_blocks_headers_no_containers() {
let (w, h) = (140, 1);
let mut setup = test_setup(w, h, true, true);
fn test_draw_blocks_headers_no_containers_show_help() {
let mut setup = test_setup(140, 1, true, true);
setup.app_data.lock().containers = StatefulList::new(vec![]);
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
let expected = [
" ( h ) show help ",
];
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
setup
.terminal
@@ -261,19 +257,24 @@ 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_snapshot!(setup.terminal.backend());
for (_, result_row) in get_result(&setup) {
for result_cell in result_row {
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
assert_eq!(result_cell.fg, Color::Gray,);
}
}
}
#[test]
/// Heading back only has show/exit help when no containers, correctly coloured
fn test_draw_blocks_headers_no_containers_exit_help() {
let mut setup = test_setup(140, 1, true, true);
setup.app_data.lock().containers = StatefulList::new(vec![]);
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
fd.status.insert(Status::Help);
let expected = [
" ( h ) exit help ",
];
setup
.terminal
.draw(|f| {
@@ -287,11 +288,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 (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 {
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(result_cell.fg, Color::Black);
}
@@ -301,13 +301,8 @@ mod tests {
#[test]
/// Show all headings when containers present, colors valid
fn test_draw_blocks_headers_some_containers() {
let (w, h) = (140, 1);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(140, 1, true, true);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
let expected = [
" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
];
setup
.terminal
.draw(|f| {
@@ -321,11 +316,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 (_, 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]);
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(
result_cell.fg,
@@ -343,12 +337,9 @@ mod tests {
#[test]
/// Only show the headings that fit the reduced-in-size header section
fn test_draw_blocks_headers_some_containers_reduced_width() {
let (w, h) = (80, 1);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(80, 1, true, true);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
let expected =
[" name state status cpu ( h ) show help "];
setup
.terminal
.draw(|f| {
@@ -363,10 +354,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 (_, 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]);
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(
result_cell.fg,
@@ -381,204 +371,14 @@ mod tests {
}
}
#[test]
/// Test all combination of headers & sort by
#[allow(clippy::too_many_lines)]
fn test_draw_blocks_headers_sort_containers() {
let (w, h) = (140, 1);
let mut setup = test_setup(w, h, true, true);
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
// Actual test, used for each header and sorted type
let mut test =
|expected: &[&str], range: RangeInclusive<usize>, x: (Header, SortedOrder)| {
fd.sorted_by = Some(x);
setup
.terminal
.draw(|f| {
super::draw(
setup.area,
AppColors::new(),
f,
&fd,
&setup.gui_state,
&Keymap::new(),
);
})
.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_eq!(result_cell.bg, Color::Magenta);
assert_eq!(
result_cell.fg,
match result_cell_index {
0..=3 => Color::White,
122..=139 => Color::Gray,
// given range | help section
x if range.contains(&x) => Color::Gray,
112..=121 => Color::Reset,
_ => Color::Black,
}
);
}
}
};
// Name
test(
&[
" name ▲ state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
],
1..=17,
(Header::Name, SortedOrder::Asc),
);
test(
&[
" name ▼ state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
],
1..=17,
(Header::Name, SortedOrder::Desc),
);
// state
test(
&[
" name state ▲ status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
],
18..=29,
(Header::State, SortedOrder::Asc),
);
test(
&[
" name state ▼ status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
],
18..=29,
(Header::State, SortedOrder::Desc),
);
// status
test(
&[
" name state status ▲ cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
],
30..=41,
(Header::Status, SortedOrder::Asc),
);
test(
&[
" name state status ▼ cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
],
30..=41,
(Header::Status, SortedOrder::Desc),
);
// cpu
test(
&[
" name state status cpu ▲ memory/limit id image ↓ rx ↑ tx ( h ) show help ",
],
42..=50,
(Header::Cpu, SortedOrder::Asc),
);
test(
&[
" name state status cpu ▼ memory/limit id image ↓ rx ↑ tx ( h ) show help ",
],
42..=50,
(Header::Cpu, SortedOrder::Desc),
);
// memory
test(
&[
" name state status cpu memory/limit ▲ id image ↓ rx ↑ tx ( h ) show help ",
],
51..=70,
(Header::Memory, SortedOrder::Asc),
);
test(
&[
" name state status cpu memory/limit ▼ id image ↓ rx ↑ tx ( h ) show help ",
],
51..=70,
(Header::Memory, SortedOrder::Desc),
);
//id
test(
&[
" name state status cpu memory/limit id ▲ image ↓ rx ↑ tx ( h ) show help ",
],
71..=81,
(Header::Id, SortedOrder::Asc),
);
test(
&[
" name state status cpu memory/limit id ▼ image ↓ rx ↑ tx ( h ) show help ",
],
71..=81,
(Header::Id, SortedOrder::Desc),
);
// image
test(
&[
" name state status cpu memory/limit id image ▲ ↓ rx ↑ tx ( h ) show help ",
],
82..=91,
(Header::Image, SortedOrder::Asc),
);
test(
&[
" name state status cpu memory/limit id image ▼ ↓ rx ↑ tx ( h ) show help ",
],
82..=91,
(Header::Image, SortedOrder::Desc),
);
// rx
test(
&[
" name state status cpu memory/limit id image ↓ rx ▲ ↑ tx ( h ) show help ",
],
92..=101,
(Header::Rx, SortedOrder::Asc),
);
test(
&[
" name state status cpu memory/limit id image ↓ rx ▼ ↑ tx ( h ) show help ",
],
92..=101,
(Header::Rx, SortedOrder::Desc),
);
// tx
test(
&[
" name state status cpu memory/limit id image ↓ rx ↑ tx ▲ ( h ) show help ",
],
102..=111,
(Header::Tx, SortedOrder::Asc),
);
test(
&[
" name state status cpu memory/limit id image ↓ rx ↑ tx ▼ ( h ) show help ",
],
102..=111,
(Header::Tx, SortedOrder::Desc),
);
}
#[test]
/// Show animation
fn test_draw_blocks_headers_animation() {
let (w, h) = (140, 1);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(140, 1, true, true);
let uuid = Uuid::new_v4();
setup.gui_state.lock().next_loading(uuid);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
let expected = [
" ⠙ name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
];
setup
.terminal
.draw(|f| {
@@ -593,10 +393,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 (_, 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]);
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(
result_cell.fg,
@@ -614,8 +413,7 @@ mod tests {
#[test]
/// Custom colors are applied correctly
fn test_draw_blocks_headers_custom_colors() {
let (w, h) = (140, 1);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(140, 1, true, true);
let uuid = Uuid::new_v4();
setup.gui_state.lock().next_loading(uuid);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
@@ -627,10 +425,6 @@ mod tests {
colors.headers_bar.text = Color::Blue;
colors.headers_bar.text_selected = Color::Yellow;
let expected = [
" ⠙ name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
];
setup
.terminal
.draw(|f| {
@@ -638,10 +432,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 (_, 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]);
assert_eq!(result_cell.bg, Color::Black);
assert_eq!(
result_cell.fg,
@@ -657,18 +451,14 @@ mod tests {
}
#[test]
/// Custom keymap for help panel is correctly display, with one and two definitions
fn test_draw_blocks_headers_custom_keymap() {
let (w, h) = (140, 1);
let mut setup = test_setup(w, h, true, true);
/// Custom keymap for help panel is correctly display, with one definitions
fn test_draw_blocks_headers_custom_keymap_one_definition() {
let mut setup = test_setup(140, 1, true, true);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
let mut keymap = Keymap::new();
keymap.toggle_help = (KeyCode::Char('T'), None);
let expected = [
" name state status cpu memory/limit id image ↓ rx ↑ tx ( T ) show help ",
];
setup
.terminal
.draw(|f| {
@@ -683,17 +473,17 @@ 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());
}
#[test]
/// Custom keymap for help panel is correctly display, two definitions
fn test_draw_blocks_headers_custom_keymap_two_definitions() {
let mut setup = test_setup(140, 1, true, true);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
let mut keymap = Keymap::new();
keymap.toggle_help = (KeyCode::Char('T'), Some(KeyCode::Tab));
let expected = [
" name state status cpu memory/limit id image ↓ rx ↑ tx ( T | Tab ) show help ",
];
setup
.terminal
.draw(|f| {
@@ -708,11 +498,178 @@ 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());
}
fn check_color(setup: &TuiTestSetup, range: RangeInclusive<usize>) {
for (_, 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]);
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(
result_cell.fg,
match result_cell_index {
0..=3 => Color::White,
122..=139 => Color::Gray,
// given range | help section
x if range.contains(&x) => Color::Gray,
112..=121 => Color::Reset,
_ => Color::Black,
}
);
}
}
}
/// As a macro - headers test, check for asc/desc icon and colors
macro_rules! test_draw_blocks_headers_sort {
($name:ident, $header:expr, $order:expr, $color_range:expr) => {
#[test]
fn $name() {
let mut setup = test_setup(140, 1, true, true);
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
fd.sorted_by = Some(($header, $order));
setup
.terminal
.draw(|f| {
super::draw(
setup.area,
AppColors::new(),
f,
&fd,
&setup.gui_state,
&Keymap::new(),
);
})
.unwrap();
assert_snapshot!(setup.terminal.backend());
check_color(&setup, $color_range);
}
};
}
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_name_asc,
Header::Name,
SortedOrder::Asc,
1..=17
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_name_desc,
Header::Name,
SortedOrder::Desc,
1..=17
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_state_asc,
Header::State,
SortedOrder::Asc,
18..=29
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_state_desc,
Header::State,
SortedOrder::Desc,
18..=29
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_status_asc,
Header::Status,
SortedOrder::Asc,
30..=41
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_status_desc,
Header::Status,
SortedOrder::Desc,
30..=41
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_cpu_asc,
Header::Cpu,
SortedOrder::Asc,
42..=50
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_cpu_desc,
Header::Cpu,
SortedOrder::Desc,
42..=50
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_memory_asc,
Header::Memory,
SortedOrder::Asc,
51..=70
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_memory_desc,
Header::Memory,
SortedOrder::Desc,
51..=70
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_id_asc,
Header::Id,
SortedOrder::Asc,
71..=81
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_id_desc,
Header::Id,
SortedOrder::Desc,
71..=81
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_image_asc,
Header::Image,
SortedOrder::Asc,
82..=91
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_image_desc,
Header::Image,
SortedOrder::Desc,
82..=91
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_rx_asc,
Header::Rx,
SortedOrder::Asc,
92..=101
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_rx_desc,
Header::Rx,
SortedOrder::Desc,
92..=101
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_tx_asc,
Header::Tx,
SortedOrder::Asc,
102..=111
);
test_draw_blocks_headers_sort!(
test_draw_blocks_headers_sort_containers_tx_desc,
Header::Tx,
SortedOrder::Desc,
102..=111
);
}
+19 -322
View File
@@ -279,7 +279,7 @@ impl HelpInfo {
km.toggle_help,
"toggle this help information - or click heading",
),
or_secondary(km.toggle_help, "save logs to file"),
or_secondary(km.save_logs, "save logs to file"),
or_secondary(
km.toggle_mouse_capture,
"toggle mouse capture - if disabled, text on screen can be selected & copied",
@@ -415,21 +415,18 @@ pub fn draw(
#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::too_many_lines)]
mod tests {
use crate::{
config::{AppColors, Keymap},
ui::draw_blocks::VERSION,
};
use crate::config::{AppColors, Keymap};
use crossterm::event::KeyCode;
use insta::assert_snapshot;
use jiff::tz::TimeZone;
use ratatui::style::{Color, Modifier};
use crate::ui::draw_blocks::tests::{expected_to_vec, get_result, test_setup};
use crate::ui::draw_blocks::tests::{get_result, test_setup};
#[test]
/// This will cause issues once the version has more than the current 5 chars (0.5.0)
fn test_draw_blocks_help() {
let (w, h) = (87, 33);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(87, 33, true, true);
let tz = setup.app_data.lock().config.timezone.clone();
setup
@@ -445,50 +442,10 @@ mod tests {
})
.unwrap();
let version_row = format!(
"{VERSION} ────────────────────────────────────────────────────────────────────────────╮ "
);
let expected = [
" ",
version_row.as_str(),
" │ │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ ",
r#" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "#,
r#" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "#,
r#" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "#,
r#" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "#,
" │ │ ",
" │ A simple tui to view & control docker containers │ ",
" │ │ ",
" │ ( tab ) or ( shift+tab ) change panels │ ",
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ ",
" │ ( enter ) send docker container command │ ",
" │ ( e ) exec into a container │ ",
" │ ( h ) toggle this help information - or click heading │ ",
" │ ( s ) save logs to file │ ",
" │ ( m ) toggle mouse capture - if disabled, text on screen can be selected & copied │ ",
" │ ( F1 ) or ( / ) enter filter mode │ ",
" │ ( 0 ) stop sort │ ",
" │ ( 1 - 9 ) sort by header - or click header │ ",
" │ ( esc ) close dialog │ ",
" │ ( q ) quit at any time │ ",
" │ │ ",
" │ currently an early work in progress, all and any input appreciated │ ",
" │ https://github.com/mrjackwills/oxker │ ",
" │ │ ",
" │ │ ",
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
" ",
];
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]);
match (row_index, result_cell_index) {
// first & last row, and first & last char on each row, is reset/reset, making sure that the help info is centered in the given area
(0 | 32, _) | (0..=33, 0 | 86) => {
@@ -531,8 +488,7 @@ mod tests {
#[test]
/// Test that the help panel gets drawn with custom colors
fn test_draw_blocks_help_custom_colors() {
let (w, h) = (87, 33);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(87, 33, true, true);
let mut colors = AppColors::new();
let tz = setup.app_data.lock().config.timezone.clone();
@@ -553,50 +509,10 @@ mod tests {
})
.unwrap();
let version_row = format!(
"{VERSION} ────────────────────────────────────────────────────────────────────────────╮ "
);
let expected = [
" ",
version_row.as_str(),
" │ │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ ",
r#" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "#,
r#" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "#,
r#" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "#,
r#" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "#,
" │ │ ",
" │ A simple tui to view & control docker containers │ ",
" │ │ ",
" │ ( tab ) or ( shift+tab ) change panels │ ",
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ ",
" │ ( enter ) send docker container command │ ",
" │ ( e ) exec into a container │ ",
" │ ( h ) toggle this help information - or click heading │ ",
" │ ( s ) save logs to file │ ",
" │ ( m ) toggle mouse capture - if disabled, text on screen can be selected & copied │ ",
" │ ( F1 ) or ( / ) enter filter mode │ ",
" │ ( 0 ) stop sort │ ",
" │ ( 1 - 9 ) sort by header - or click header │ ",
" │ ( esc ) close dialog │ ",
" │ ( q ) quit at any time │ ",
" │ │ ",
" │ currently an early work in progress, all and any input appreciated │ ",
" │ https://github.com/mrjackwills/oxker │ ",
" │ │ ",
" │ │ ",
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
" ",
];
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]);
match (row_index, result_cell_index) {
// first & last row, and first & last char on each row, is reset/reset, making sure that the help info is centered in the given area
(0 | 32, _) | (0..=33, 0 | 86) => {
@@ -639,8 +555,7 @@ mod tests {
#[test]
/// Help panel will show custom keymap if in use, with one definition for each entry
fn test_draw_blocks_help_custom_keymap_one_definition() {
let (w, h) = (98, 47);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(98, 47, true, true);
let input = Keymap {
clear: (KeyCode::Char('a'), None),
@@ -679,72 +594,13 @@ mod tests {
})
.unwrap();
let version_row = format!(
"{VERSION} ─────────────────────────────────────────────────────────────────────────────────────╮ "
);
let expected = [
" ",
version_row.as_str(),
" │ │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ ",
r#" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "#,
r#" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "#,
r#" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "#,
r#" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "#,
" │ │ ",
" │ A simple tui to view & control docker containers │ ",
" │ │ ",
" │ ( 0 ) select next panel │ ",
" │ ( 2 ) select previous panel │ ",
" │ ( q ) scroll list down by one │ ",
" │ ( y ) scroll list up by one │ ",
" │ ( o ) scroll list down by many │ ",
" │ ( w ) scroll list by up many │ ",
" │ ( s ) scroll list to end │ ",
" │ ( u ) scroll list to start │ ",
" │ ( enter ) send docker container command │ ",
" │ ( g ) exec into a container │ ",
" │ ( Home ) toggle this help information - or click heading │ ",
" │ ( Home ) save logs to file │ ",
" │ ( Page Down ) toggle mouse capture - if disabled, text on screen can be selected & copied │ ",
" │ ( i ) enter filter mode │ ",
" │ ( Up ) reset container sorting │ ",
" │ ( 4 ) sort containers by name │ ",
" │ ( 6 ) sort containers by state │ ",
" │ ( 8 ) sort containers by status │ ",
" │ ( F1 ) sort containers by cpu │ ",
" │ ( # ) sort containers by memory │ ",
" │ ( / ) sort containers by id │ ",
" │ ( , ) sort containers by image │ ",
" │ ( . ) sort containers by rx │ ",
" │ ( Backspace ) sort containers by tx │ ",
" │ ( a ) close dialog │ ",
" │ ( k ) quit at any time │ ",
" │ │ ",
" │ currently an early work in progress, all and any input appreciated │ ",
" │ https://github.com/mrjackwills/oxker │ ",
" │ │ ",
" │ │ ",
" ╰────────────────────────────────────────────────────────────────────────────────────────────╯ ",
" ",
];
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());
}
#[test]
/// Help panel will show custom keymap if in use, with two definition for each entry
fn test_draw_blocks_help_custom_keymap_two_definitions() {
let (w, h) = (110, 47);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(110, 47, true, true);
let keymap = Keymap {
clear: (KeyCode::Char('a'), Some(KeyCode::Char('b'))),
@@ -783,72 +639,13 @@ mod tests {
})
.unwrap();
let version_row = format!(
"{VERSION} ───────────────────────────────────────────────────────────────────────────────────────────────────╮ "
);
let expected = [
" ",
version_row.as_str(),
" │ │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ ",
r#" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "#,
r#" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "#,
r#" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "#,
r#" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "#,
" │ │ ",
" │ A simple tui to view & control docker containers │ ",
" │ │ ",
" │ ( 0 ) or ( 1 ) select next panel │ ",
" │ ( 2 ) or ( 3 ) select previous panel │ ",
" │ ( q ) or ( r ) scroll list down by one │ ",
" │ ( y ) or ( z ) scroll list up by one │ ",
" │ ( o ) or ( p ) scroll list down by many │ ",
" │ ( w ) or ( x ) scroll list by up many │ ",
" │ ( s ) or ( t ) scroll list to end │ ",
" │ ( u ) or ( v ) scroll list to start │ ",
" │ ( enter ) send docker container command │ ",
" │ ( g ) or ( h ) exec into a container │ ",
" │ ( Home ) or ( Del ) toggle this help information - or click heading │ ",
" │ ( Home ) or ( Del ) save logs to file │ ",
" │ ( Page Down ) or ( Page Up ) toggle mouse capture - if disabled, text on screen can be selected & copied │ ",
" │ ( i ) or ( j ) enter filter mode │ ",
" │ ( Up ) or ( Down ) reset container sorting │ ",
" │ ( 4 ) or ( 5 ) sort containers by name │ ",
" │ ( 6 ) or ( 7 ) sort containers by state │ ",
" │ ( 8 ) or ( 9 ) sort containers by status │ ",
" │ ( F1 ) or ( F12 ) sort containers by cpu │ ",
" │ ( # ) or ( - ) sort containers by memory │ ",
" │ ( / ) or ( = ) sort containers by id │ ",
r" │ ( , ) or ( \ ) sort containers by image │ ",
" │ ( . ) or ( ] ) sort containers by rx │ ",
" │ ( Backspace ) or ( Back Tab ) sort containers by tx │ ",
" │ ( a ) or ( b ) close dialog │ ",
" │ ( k ) or ( l ) quit at any time │ ",
" │ │ ",
" │ currently an early work in progress, all and any input appreciated │ ",
" │ https://github.com/mrjackwills/oxker │ ",
" │ │ ",
" │ │ ",
" ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ",
" ",
];
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());
}
#[test]
/// Help panel will show custom keymap if in use, with either one or two definition for each entry
fn test_draw_blocks_help_one_and_two_definitions() {
let (w, h) = (110, 47);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(110, 47, true, true);
let keymap = Keymap {
clear: (KeyCode::Char('a'), Some(KeyCode::Char('b'))),
@@ -889,71 +686,12 @@ mod tests {
})
.unwrap();
let version_row = format!(
"{VERSION} ───────────────────────────────────────────────────────────────────────────────────────────────────╮ "
);
let expected = [
" ",
version_row.as_str(),
" │ │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ ",
r#" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "#,
r#" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "#,
r#" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "#,
r#" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "#,
" │ │ ",
" │ A simple tui to view & control docker containers │ ",
" │ │ ",
" │ ( 0 ) select next panel │ ",
" │ ( 2 ) or ( 3 ) select previous panel │ ",
" │ ( q ) or ( r ) scroll list down by one │ ",
" │ ( y ) or ( z ) scroll list up by one │ ",
" │ ( o ) scroll list down by many │ ",
" │ ( w ) scroll list by up many │ ",
" │ ( s ) scroll list to end │ ",
" │ ( u ) or ( v ) scroll list to start │ ",
" │ ( enter ) send docker container command │ ",
" │ ( g ) exec into a container │ ",
" │ ( Home ) toggle this help information - or click heading │ ",
" │ ( Home ) save logs to file │ ",
" │ ( Page Down ) or ( Page Up ) toggle mouse capture - if disabled, text on screen can be selected & copied │ ",
" │ ( i ) or ( j ) enter filter mode │ ",
" │ ( Up ) or ( Down ) reset container sorting │ ",
" │ ( 4 ) sort containers by name │ ",
" │ ( 6 ) or ( 7 ) sort containers by state │ ",
" │ ( 8 ) sort containers by status │ ",
" │ ( F1 ) or ( F12 ) sort containers by cpu │ ",
" │ ( # ) sort containers by memory │ ",
" │ ( / ) or ( = ) sort containers by id │ ",
" │ ( , ) sort containers by image │ ",
" │ ( . ) or ( ] ) sort containers by rx │ ",
" │ ( Backspace ) sort containers by tx │ ",
" │ ( a ) or ( b ) close dialog │ ",
" │ ( k ) quit at any time │ ",
" │ │ ",
" │ currently an early work in progress, all and any input appreciated │ ",
" │ https://github.com/mrjackwills/oxker │ ",
" │ │ ",
" │ │ ",
" ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ",
" ",
];
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());
}
#[test]
fn test_draw_blocks_help_show_timezone() {
let (w, h) = (87, 35);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(87, 35, true, true);
setup
.terminal
@@ -968,49 +706,9 @@ mod tests {
})
.unwrap();
let version_row = format!(
"{VERSION} ────────────────────────────────────────────────────────────────────────────╮ "
);
let expected = [
" ",
version_row.as_str(),
" │ │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ 88 │ ",
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ ",
r#" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "#,
r#" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "#,
r#" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "#,
r#" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "#,
" │ │ ",
" │ A simple tui to view & control docker containers │ ",
" │ │ ",
" │ logs timezone: Asia/Tokyo │ ",
" │ │ ",
" │ ( tab ) or ( shift+tab ) change panels │ ",
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ ",
" │ ( enter ) send docker container command │ ",
" │ ( e ) exec into a container │ ",
" │ ( h ) toggle this help information - or click heading │ ",
" │ ( s ) save logs to file │ ",
" │ ( m ) toggle mouse capture - if disabled, text on screen can be selected & copied │ ",
" │ ( F1 ) or ( / ) enter filter mode │ ",
" │ ( 0 ) stop sort │ ",
" │ ( 1 - 9 ) sort by header - or click header │ ",
" │ ( esc ) close dialog │ ",
" │ ( q ) quit at any time │ ",
" │ │ ",
" │ currently an early work in progress, all and any input appreciated │ ",
" │ https://github.com/mrjackwills/oxker │ ",
" │ │ ",
" │ │ ",
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
" ",
];
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() {
match (row_index, result_cell_index) {
(14, 31..=45) => {
@@ -1021,7 +719,6 @@ mod tests {
}
_ => (),
}
assert_eq!(result_cell.symbol(), expected_row[result_cell_index]);
}
}
}
+9 -35
View File
@@ -57,30 +57,19 @@ pub fn draw(
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use insta::assert_snapshot;
use ratatui::style::Color;
use crate::{
config::AppColors,
ui::draw_blocks::tests::{expected_to_vec, get_result, test_setup},
ui::draw_blocks::tests::{get_result, test_setup},
};
#[test]
/// Info box drawn in bottom right
fn test_draw_blocks_info() {
let (w, h) = (45, 9);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(45, 9, true, true);
let expected = [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" test ",
" ",
];
let colors = setup.app_data.lock().config.app_colors;
setup
@@ -96,11 +85,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() {
let (bg, fg) = match (row_index, result_cell_index) {
(6..=8, 32..=44) => (Color::Blue, Color::White),
_ => (Color::Reset, Color::Reset),
@@ -114,23 +102,11 @@ mod tests {
#[test]
/// Info box drawn in bottom right with custom colors applied
fn test_draw_blocks_info_custom_color() {
let (w, h) = (45, 9);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(45, 9, true, true);
let mut colors = AppColors::new();
colors.popup_info.background = Color::Red;
colors.popup_info.text = Color::Black;
let expected = [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" test ",
" ",
];
setup
.terminal
@@ -145,11 +121,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]);
let (bg, fg) = match (row_index, result_cell_index) {
(6..=8, 32..=44) => (Color::Red, Color::Black),
_ => (Color::Reset, Color::Reset),
+70 -142
View File
@@ -74,6 +74,7 @@ pub fn draw(
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use insta::assert_snapshot;
use ratatui::style::{Color, Modifier};
use uuid::Uuid;
@@ -82,26 +83,15 @@ mod tests {
config::AppColors,
ui::{
FrameData, Status,
draw_blocks::tests::{
BORDER_CHARS, expected_to_vec, get_result, insert_logs, test_setup,
},
draw_blocks::tests::{BORDER_CHARS, get_result, insert_logs, test_setup},
},
};
#[test]
/// No logs, panel unselected, then selected, border color changes correctly
fn test_draw_blocks_logs_none() {
let (w, h) = (35, 6);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(35, 6, true, true);
let expected = [
"╭ Logs - container_1 - image_1 ───╮",
"│ no logs found │",
"│ │",
"│ │",
"│ │",
"╰─────────────────────────────────╯",
];
let colors = setup.app_data.lock().config.app_colors;
setup
@@ -117,11 +107,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]);
match (row_index, result_cell_index) {
(0 | 5, 0..=34) | (1..=4, 0) | (1..=5, 34) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -154,10 +143,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);
}
@@ -166,22 +153,12 @@ mod tests {
}
#[test]
/// Parsing logs, spinner visible, and then animates by one frame
fn test_draw_blocks_logs_parsing() {
let (w, h) = (32, 6);
let mut setup = test_setup(w, h, true, true);
/// Parsing logs, first frame spinner visible
fn test_draw_blocks_logs_parsing_frame_one() {
let mut setup = test_setup(32, 6, true, true);
let uuid = Uuid::new_v4();
setup.gui_state.lock().next_loading(uuid);
let expected = [
"╭ Logs - container_1 - image_1 ╮",
"│ parsing logs ⠙ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────╯",
];
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
fd.status.insert(Status::Init);
@@ -199,11 +176,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]);
match (row_index, result_cell_index) {
(0, 0..=31) | (1..=4, 0) | (1..=5, 31) | (5, 0..=30) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -216,19 +191,20 @@ mod tests {
}
}
}
}
#[test]
/// Parsing logs, second frame spinner visible
fn test_draw_blocks_logs_parsing_frame_two() {
let mut setup = test_setup(32, 6, true, true);
let uuid = Uuid::new_v4();
setup.gui_state.lock().next_loading(uuid);
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
fd.status.insert(Status::Init);
// animation moved by one frame
setup.gui_state.lock().next_loading(uuid);
let expected = [
"╭ Logs - container_1 - image_1 ╮",
"│ parsing logs ⠹ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────╯",
];
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
fd.status.insert(Status::Init);
setup
@@ -245,10 +221,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) {
(0, 0..=31) | (1..=4, 0) | (1..=5, 31) | (5, 0..=30) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -265,9 +241,8 @@ mod tests {
#[test]
/// Logs correct displayed, changing log state also draws correctly
fn test_draw_blocks_logs_some() {
let (w, h) = (36, 6);
let mut setup = test_setup(w, h, true, true);
fn test_draw_blocks_logs_some_line_three() {
let mut setup = test_setup(36, 6, true, true);
insert_logs(&setup);
@@ -285,19 +260,12 @@ mod tests {
);
})
.unwrap();
let expected = [
"╭ Logs 3/3 - container_1 - image_1 ╮",
"│ line 1 │",
"│ line 2 │",
"│▶ line 3 │",
"│ │",
"╰──────────────────────────────────╯",
];
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) {
// 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_eq!(result_cell.symbol(), expected_row[result_cell_index]);
assert_eq!(result_cell.bg, Color::Reset);
if let (1..=4, 1..=34) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Reset);
@@ -311,7 +279,28 @@ mod tests {
}
}
}
// Change selected log line
}
#[test]
/// Logs correct displayed, changing log state also draws correctly
fn test_draw_blocks_logs_some_line_two() {
let mut setup = test_setup(36, 6, true, true);
insert_logs(&setup);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
setup
.terminal
.draw(|f| {
super::draw(
&setup.app_data,
setup.area,
AppColors::new(),
f,
&fd,
&setup.gui_state,
);
})
.unwrap();
setup.app_data.lock().log_previous();
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
@@ -329,19 +318,10 @@ mod tests {
})
.unwrap();
let expected = [
"╭ Logs 2/3 - container_1 - image_1 ╮",
"│ line 1 │",
"│▶ line 2 │",
"│ line 3 │",
"│ │",
"╰──────────────────────────────────╯",
];
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]);
assert_eq!(result_cell.bg, Color::Reset);
if let (1..=4, 1..=34) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Reset);
@@ -360,23 +340,13 @@ mod tests {
#[test]
/// Full (long) name displayed in logs border
fn test_draw_blocks_logs_long_name() {
let (w, h) = (80, 6);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(80, 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");
insert_logs(&setup);
let expected = [
"╭ Logs 3/3 - a_long_container_name_for_the_purposes_of_this_test - a_long_image╮",
"│ line 1 │",
"│ line 2 │",
"│▶ line 3 │",
"│ │",
"╰──────────────────────────────────────────────────────────────────────────────╯",
];
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
setup
@@ -393,30 +363,15 @@ 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());
}
#[test]
fn test_draw_blocks_logs_custom_colors_parsing() {
let (w, h) = (32, 6);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(32, 6, true, true);
let uuid = Uuid::new_v4();
setup.gui_state.lock().next_loading(uuid);
let expected = [
"╭ Logs - container_1 - image_1 ╮",
"│ parsing logs ⠙ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────╯",
];
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
fd.status.insert(Status::Init);
@@ -438,11 +393,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]);
assert_eq!(result_cell.bg, Color::Green);
if let (1..=4, 1..=29) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Black);
@@ -466,11 +420,8 @@ mod tests {
})
.unwrap();
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]);
assert_eq!(result_cell.bg, Color::Reset);
if let (1..=4, 1..=29) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Reset);
@@ -482,17 +433,8 @@ mod tests {
#[test]
fn test_draw_blocks_logs_custom_colors_no_logs() {
let (w, h) = (35, 6);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(35, 6, true, true);
let expected = [
"╭ Logs - container_1 - image_1 ───╮",
"│ no logs found │",
"│ │",
"│ │",
"│ │",
"╰─────────────────────────────────╯",
];
let mut colors = AppColors::new();
colors.logs.background = Color::Green;
colors.logs.text = Color::Black;
@@ -511,10 +453,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]);
assert_eq!(result_cell.bg, Color::Green);
if let (1..=4, 1..=29) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Black);
@@ -537,10 +479,8 @@ mod tests {
})
.unwrap();
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]);
assert_eq!(result_cell.bg, Color::Reset);
if let (1..=4, 1..=29) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Reset);
@@ -552,8 +492,7 @@ mod tests {
#[test]
/// Logs correct displayed with custom colors
fn test_draw_blocks_logs_custom_colors_logs() {
let (w, h) = (36, 6);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(36, 6, true, true);
insert_logs(&setup);
let mut colors = setup.app_data.lock().config.app_colors;
@@ -576,19 +515,10 @@ mod tests {
);
})
.unwrap();
let expected = [
"╭ Logs 3/3 - container_1 - image_1 ╮",
"│ line 1 │",
"│ line 2 │",
"│▶ line 3 │",
"│ │",
"╰──────────────────────────────────╯",
];
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]);
assert_eq!(result_cell.bg, Color::Reset);
if let (1..=4, 1..=34) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Reset);
@@ -617,10 +547,8 @@ mod tests {
})
.unwrap();
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]);
assert_eq!(result_cell.bg, Color::Green);
if let (1..=4, 1..=34) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Black);
+10 -180
View File
@@ -117,6 +117,7 @@ pub mod tests {
sync::Arc,
};
use insta::assert_snapshot;
use parking_lot::Mutex;
use ratatui::{Terminal, backend::TestBackend, layout::Rect, style::Color};
@@ -211,25 +212,17 @@ pub mod tests {
}
}
/// Get a single row of String's from the expected data
pub fn expected_to_vec(expected: &[&str], row_index: usize) -> Vec<String> {
expected[row_index]
.chars()
.map(|i| i.to_string())
.collect::<Vec<_>>()
}
/// Just a shorthand for when enumerating over result cells
pub fn get_result(
setup: &TuiTestSetup,
w: u16,
// w: u16,
) -> std::iter::Enumerate<std::slice::Chunks<ratatui::buffer::Cell>> {
setup
.terminal
.backend()
.buffer()
.content
.chunks(usize::from(w))
.chunks(usize::from(setup.area.width))
.enumerate()
}
@@ -270,8 +263,7 @@ pub mod tests {
#[test]
/// Check that the whole layout is drawn correctly
fn test_draw_blocks_whole_layout() {
let (w, h) = (160, 30);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(160, 30, true, true);
insert_chart_data(&setup);
insert_logs(&setup);
@@ -282,39 +274,6 @@ pub mod tests {
private: 8003,
public: Some(8003),
});
let expected = [
" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
"╭ Containers 1/3 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮╭──────────────╮",
"│⚪ container_1 ✓ running Up 1 hour 03.00% 30.00 kB / 30.00 kB 1 image_1 0.00 kB 0.00 kB ││▶ pause │",
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB ││ restart │",
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB ││ stop │",
"│ ││ delete │",
"│ ││ │",
"│ ││ │",
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯╰──────────────╯",
"╭ Logs 3/3 - container_1 - image_1 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
"│ line 1 │",
"│ line 2 │",
"│▶ line 3 │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮",
"│10.00%│ •••• ││100.00 kB│ ••• ││ ip private public│",
"│ │ ••• • ││ │ ••• • ││ 8001 │",
"│ │•• ••• ││ │•• ••• ││127.0.0.1 8003 8003│",
"│ │ ││ │ ││ │",
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯",
];
let colors = setup.app_data.lock().config.app_colors;
let keymap = setup.app_data.lock().config.keymap.clone();
@@ -326,20 +285,14 @@ pub 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());
}
#[test]
#[allow(clippy::too_many_lines)]
/// Check that the whole layout is drawn correctly
fn test_draw_blocks_whole_layout_with_filter() {
let (w, h) = (160, 30);
let mut setup = test_setup(w, h, true, true);
fn test_draw_blocks_whole_layout_with_filter_bar() {
let mut setup = test_setup(160, 30, true, true);
insert_chart_data(&setup);
insert_logs(&setup);
@@ -351,55 +304,8 @@ pub mod tests {
public: Some(8003),
});
let expected = [
" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
"╭ Containers 1/3 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮╭──────────────╮",
"│⚪ container_1 ✓ running Up 1 hour 03.00% 30.00 kB / 30.00 kB 1 image_1 0.00 kB 0.00 kB ││▶ pause │",
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB ││ restart │",
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB ││ stop │",
"│ ││ delete │",
"│ ││ │",
"│ ││ │",
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯╰──────────────╯",
"╭ Logs 3/3 - container_1 - image_1 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
"│ line 1 │",
"│ line 2 │",
"│▶ line 3 │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮",
"│10.00%│ •••• ││100.00 kB│ ••• ││ ip private public│",
"│ │ ••• • ││ │ ••• • ││ 8001 │",
"│ │•• ••• ││ │•• ••• ││ │",
"│ │ ││ │ ││ │",
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯",
];
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
let colors = setup.app_data.lock().config.app_colors;
let keymap = setup.app_data.lock().config.keymap.clone();
setup
.terminal
.draw(|f| {
draw_frame(&setup.app_data, colors, &keymap, f, &fd, &setup.gui_state);
})
.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]);
}
}
setup
.gui_state
.lock()
@@ -407,39 +313,6 @@ pub mod tests {
setup.app_data.lock().filter_term_push('r');
setup.app_data.lock().filter_term_push('_');
setup.app_data.lock().filter_term_push('1');
let expected = [
" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
"╭ Containers 1/1 - filtered ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮╭──────────────╮",
"│⚪ container_1 ✓ running Up 1 hour 03.00% 30.00 kB / 30.00 kB 1 image_1 0.00 kB 0.00 kB ││▶ pause │",
"│ ││ restart │",
"│ ││ stop │",
"│ ││ delete │",
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯╰──────────────╯",
"╭ Logs 3/3 - container_1 - image_1 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
"│ line 1 │",
"│ line 2 │",
"│▶ line 3 │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮",
"│10.00%│ ••• ││100.00 kB│ •• ││ ip private public│",
"│ │ •• • ││ │ •• • ││ 8001 │",
"│ │ ••• • • ││ │ ••• • • ││ │",
"│ │• •• ││ │• •• ││ │",
"│ │ ││ │ ││ │",
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯",
" Esc clear ← by → Name Image Status All term: r_1 ",
];
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
setup
.terminal
@@ -448,19 +321,13 @@ pub 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());
}
#[test]
/// Check that the whole layout is drawn correctly when have long container name and long image name
fn test_draw_blocks_whole_layout_long_name() {
let (w, h) = (190, 30);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(190, 30, true, true);
insert_chart_data(&setup);
insert_logs(&setup);
@@ -477,38 +344,6 @@ pub mod tests {
setup.app_data.lock().containers.items[0].image =
ContainerImage::from("a_long_image_name_for_the_purposes_of_this_test");
let expected = [
" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
"╭ Containers 1/3 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮╭─────────────────╮",
"│⚪ a_long_container_name_for_the… ✓ running Up 1 hour 03.00% 30.00 kB / 30.00 kB 1 a_long_image_name_for_the_pur… 0.00 kB 0.00 kB ││▶ pause │",
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB ││ restart │",
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB ││ stop │",
"│ ││ delete │",
"│ ││ │",
"│ ││ │",
"╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯╰─────────────────╯",
"╭ Logs 3/3 - a_long_container_name_for_the_purposes_of_this_test - a_long_image_name_for_the_purposes_of_this_test ──────────────────────────────────────────────────────────────────────────╮",
"│ line 1 │",
"│ line 2 │",
"│▶ line 3 │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
"╭───────────────────────────────── cpu 03.00% ─────────────────────────────────╮╭────────────────────────────── memory 30.00 kB ───────────────────────────────╮╭────────── ports ───────────╮",
"│10.00%│ •••• ││100.00 kB│ ••••• ││ ip private public│",
"│ │ •••• • ││ │ ••• • ││ 8001 │",
"│ │••• •••• ││ │••• ••• ││127.0.0.1 8003 8003│",
"│ │ ││ │ ││ │",
"╰──────────────────────────────────────────────────────────────────────────────╯╰──────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────╯",
];
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
let colors = setup.app_data.lock().config.app_colors;
let keymap = setup.app_data.lock().config.keymap.clone();
@@ -519,11 +354,6 @@ pub 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());
}
}
+39 -102
View File
@@ -76,6 +76,7 @@ pub fn draw(area: Rect, colors: AppColors, f: &mut Frame, fd: &FrameData) {
mod tests {
use std::net::{IpAddr, Ipv4Addr};
use insta::assert_snapshot;
use ratatui::style::{Color, Modifier};
use crate::{
@@ -83,17 +84,14 @@ mod tests {
config::AppColors,
ui::{
FrameData,
draw_blocks::tests::{
COLOR_ORANGE, COLOR_RX, COLOR_TX, expected_to_vec, get_result, test_setup,
},
draw_blocks::tests::{COLOR_ORANGE, COLOR_RX, COLOR_TX, get_result, test_setup},
},
};
#[test]
/// Port section when container has no ports
fn test_draw_blocks_ports_no_ports() {
let (w, h) = (30, 8);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(30, 8, true, true);
setup.app_data.lock().containers.items[0].ports = vec![];
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
@@ -103,22 +101,10 @@ mod tests {
super::draw(setup.area, setup.app_data.lock().config.app_colors, f, &fd);
})
.unwrap();
assert_snapshot!(setup.terminal.backend());
let expected = [
"╭────────── ports ───────────╮",
"│ no ports │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰────────────────────────────╯",
];
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]);
match (row_index, result_cell_index) {
(0, 11..=17) => {
assert_eq!(result_cell.bg, Color::Reset);
@@ -138,8 +124,24 @@ mod tests {
}
}
}
}
#[test]
/// Port section when container has no ports
// When state is "State::Running | State::Paused | State::Restarting, won't show "no ports"
fn test_draw_blocks_ports_no_ports_dead() {
let mut setup = test_setup(30, 8, true, true);
setup.app_data.lock().containers.items[0].ports = vec![];
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
setup
.terminal
.draw(|f| {
super::draw(setup.area, setup.app_data.lock().config.app_colors, f, &fd);
})
.unwrap();
// split
// When state is "State::Running | State::Paused | State::Restarting, won't show "no ports"
setup.app_data.lock().containers.items[0].state = State::Dead;
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
@@ -150,21 +152,10 @@ mod tests {
})
.unwrap();
let expected = [
"╭────────── ports ───────────╮",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰────────────────────────────╯",
];
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]);
assert_eq!(result_cell.bg, Color::Reset);
if let (0, 11..=17) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Red);
@@ -180,8 +171,7 @@ mod tests {
#[test]
/// Port section when container has multiple ports
fn test_draw_blocks_ports_multiple_ports() {
let (w, h) = (32, 8);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(32, 8, true, true);
setup.app_data.lock().containers.items[0]
.ports
.push(ContainerPorts {
@@ -204,22 +194,10 @@ mod tests {
super::draw(setup.area, setup.app_data.lock().config.app_colors, f, &fd);
})
.unwrap();
assert_snapshot!(setup.terminal.backend());
let expected = [
"╭─────────── ports ────────────╮",
"│ ip private public │",
"│ 8001 │",
"│ 8002 │",
"│127.0.0.1 8003 8003 │",
"│ │",
"│ │",
"╰──────────────────────────────╯",
];
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]);
assert_eq!(result_cell.bg, Color::Reset);
match (row_index, result_cell_index) {
@@ -247,8 +225,7 @@ mod tests {
#[test]
/// Port section title color correct dependant on state
fn test_draw_blocks_ports_container_state() {
let (w, h) = (32, 8);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(32, 8, true, true);
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
setup
@@ -258,21 +235,10 @@ mod tests {
})
.unwrap();
let expected = [
"╭─────────── ports ────────────╮",
"│ ip private public │",
"│ 8001 │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────╯",
];
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]);
assert_eq!(result_cell.bg, Color::Reset);
if let (0, 12..=18) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Green);
@@ -290,10 +256,8 @@ mod tests {
})
.unwrap();
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]);
assert_eq!(result_cell.bg, Color::Reset);
if let (0, 12..=18) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Yellow);
@@ -311,10 +275,8 @@ mod tests {
})
.unwrap();
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]);
assert_eq!(result_cell.bg, Color::Reset);
if let (0, 12..=18) = (row_index, result_cell_index) {
assert_eq!(result_cell.fg, Color::Red);
@@ -327,8 +289,7 @@ mod tests {
#[test]
/// Custom colors applied to ports panel
fn test_draw_blocks_ports_custom_colors() {
let (w, h) = (32, 8);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(32, 8, true, true);
let mut colors = AppColors::new();
colors.chart_ports.background = Color::Black;
@@ -345,21 +306,10 @@ mod tests {
})
.unwrap();
let expected = [
"╭─────────── ports ────────────╮",
"│ ip private public │",
"│ 8001 │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────╯",
];
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]);
assert_eq!(result_cell.bg, Color::Black);
match (row_index, result_cell_index) {
@@ -387,8 +337,7 @@ mod tests {
#[test]
// Custom state color applied to ports panel title
fn test_draw_blocks_ports_custom_colors_state() {
let (w, h) = (32, 8);
let mut setup = test_setup(w, h, true, true);
let mut setup = test_setup(32, 8, true, true);
let mut colors = AppColors::new();
colors.container_state.dead = Color::Green;
@@ -402,17 +351,6 @@ mod tests {
colors.chart_ports.title = Color::DarkGray;
let expected = [
"╭─────────── ports ────────────╮",
"│ ip private public │",
"│ 8001 │",
"│ │",
"│ │",
"│ │",
"│ │",
"╰──────────────────────────────╯",
];
for i in [
(State::Dead, Color::Green),
(State::Exited, Color::Magenta),
@@ -433,11 +371,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() {
if row_index == 0 && (12..=18).contains(&result_cell_index) {
assert_eq!(result_cell.fg, i.1);
}
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮"
"│10.00%│ • ││100.00 kB│ •• │"
"│ │ •• ││ │ •• │"
"│ │ ••• ││ │ • • │"
"│ │ • • ││ │ • • │"
"│ │ • •• ││ │•• •• │"
"│ │• • ││ │• • │"
"│ │• • ││ │• • │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮"
"│10.00%│ • ││100.00 kB│ •• │"
"│ │ •• ││ │ •• │"
"│ │ ••• ││ │ • • │"
"│ │ • • ││ │ • • │"
"│ │ • •• ││ │•• •• │"
"│ │• • ││ │• • │"
"│ │• • ││ │• • │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮"
"│10.00%│ • ││100.00 kB│ •• │"
"│ │ •• ││ │ •• │"
"│ │ ••• ││ │ • • │"
"│ │ • • ││ │ • • │"
"│ │ • •• ││ │•• •• │"
"│ │• • ││ │• • │"
"│ │• • ││ │• • │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 00.00% ─────────────╮╭─────────── memory 0.00 kB ───────────╮"
"│00.00%│ ││0.00 kB│ │"
"│ │ ││ │ │"
"│ │ ││ │ │"
"│ │ ││ │ │"
"│ │ ││ │ │"
"│ │ ││ │ │"
"│ │ ││ │ │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮"
"│10.00%│ • ││100.00 kB│ •• │"
"│ │ •• ││ │ •• │"
"│ │ ••• ││ │ • • │"
"│ │ • • ││ │ • • │"
"│ │ • •• ││ │•• •• │"
"│ │• • ││ │• • │"
"│ │• • ││ │• • │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/commands.rs
expression: setup.terminal.backend()
---
"╭──────────╮"
"│ resume │"
"│▶ stop │"
"│ delete │"
"│ │"
"╰──────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/commands.rs
expression: setup.terminal.backend()
---
"╭──────────╮"
"│▶ pause │"
"│ restart │"
"│ stop │"
"│ delete │"
"╰──────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/commands.rs
expression: setup.terminal.backend()
---
"╭──────────╮"
"│ │"
"│ │"
"│ │"
"│ │"
"╰──────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/commands.rs
expression: setup.terminal.backend()
---
"╭──────────╮"
"│▶ pause │"
"│ restart │"
"│ stop │"
"│ delete │"
"╰──────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/commands.rs
expression: setup.terminal.backend()
---
"╭──────────╮"
"│▶ pause │"
"│ restart │"
"│ stop │"
"│ delete │"
"╰──────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/commands.rs
expression: setup.terminal.backend()
---
"╭──────────╮"
"│ resume │"
"│▶ stop │"
"│ delete │"
"│ │"
"╰──────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ Containers ──────────────────────────╮"
"│ no containers running │"
"│ │"
"│ │"
"│ │"
"╰──────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,10 @@
---
source: src/ui/draw_blocks/containers.rs
expression: setup.terminal.backend()
---
"╭ 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 │" Hidden by multi-width symbols: [(2, " ")]
"│ 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 │"
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/delete_confirm.rs
expression: setup.terminal.backend()
---
" "
" ╭──────────────────────── Confirm Delete ────────────────────────╮ "
" │ │ "
" │ Are you sure you want to delete container: container_1 │ "
" │ │ "
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ "
" │ │ ( n ) no │ │ ( y ) yes │ │ "
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ "
" ╰────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/delete_confirm.rs
expression: setup.terminal.backend()
---
" "
" ╭──────────────────────── Confirm Delete ────────────────────────╮ "
" │ │ "
" │ Are you sure you want to delete container: container_1 │ "
" │ │ "
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ "
" │ │ ( n ) no │ │ ( y ) yes │ │ "
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ "
" ╰────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/delete_confirm.rs
expression: setup.terminal.backend()
---
" "
" ╭──────────────────────── Confirm Delete ────────────────────────╮ "
" │ │ "
" │ Are you sure you want to delete container: container_1 │ "
" │ │ "
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ "
" │ │ ( End ) no │ │ ( F10 ) yes │ │ "
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ "
" ╰────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/delete_confirm.rs
expression: setup.terminal.backend()
---
" "
" ╭──────────────────────── Confirm Delete ────────────────────────╮ "
" │ │ "
" │ Are you sure you want to delete container: container_1 │ "
" │ │ "
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ "
" │ │ ( End | Up ) no │ │ ( F10 ) yes │ │ "
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ "
" ╰────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/delete_confirm.rs
expression: setup.terminal.backend()
---
" "
" ╭──────────────────────── Confirm Delete ────────────────────────╮ "
" │ │ "
" │ Are you sure you want to delete container: container_1 │ "
" │ │ "
" │ ╭─────────────────────╮ ╭─────────────────────╮ │ "
" │ │ ( End | Up ) no │ │ ( F10 | L ) yes │ │ "
" │ ╰─────────────────────╯ ╰─────────────────────╯ │ "
" ╰────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,14 @@
---
source: src/ui/draw_blocks/delete_confirm.rs
expression: setup.terminal.backend()
---
" "
" ╭──────────────────────────────────── Confirm Delete ────────────────────────────────────╮ "
" │ │ "
" │ Are you sure you want to delete container: container_1_container_1_container_1 │ "
" │ │ "
" │ ╭──────────────────────────────╮ ╭─────────────────────────────╮ │ "
" │ │ ( n ) no │ │ ( y ) yes │ │ "
" │ ╰──────────────────────────────╯ ╰─────────────────────────────╯ │ "
" ╰────────────────────────────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,15 @@
---
source: src/ui/draw_blocks/error.rs
expression: setup.terminal.backend()
---
" "
" ╭────────────── Error ──────────────╮ "
" │ │ "
" │ Unable to exec into container │ "
" │ │ "
" │ ( c ) clear error │ "
" │ │ "
" │ ( q ) quit oxker │ "
" │ │ "
" ╰───────────────────────────────────╯ "
" "
@@ -0,0 +1,15 @@
---
source: src/ui/draw_blocks/error.rs
expression: setup.terminal.backend()
---
" "
" ╭────────────── Error ──────────────╮ "
" │ │ "
" │ Unable to exec into container │ "
" │ │ "
" │ ( c ) clear error │ "
" │ │ "
" │ ( q ) quit oxker │ "
" │ │ "
" ╰───────────────────────────────────╯ "
" "
@@ -0,0 +1,15 @@
---
source: src/ui/draw_blocks/error.rs
expression: setup.terminal.backend()
---
" "
" ╭────────────── Error ──────────────╮ "
" │ │ "
" │ Unable to exec into container │ "
" │ │ "
" │ ( Back Tab ) clear error │ "
" │ │ "
" │ ( F4 ) quit oxker │ "
" │ │ "
" ╰───────────────────────────────────╯ "
" "
@@ -0,0 +1,15 @@
---
source: src/ui/draw_blocks/error.rs
expression: setup.terminal.backend()
---
" "
" ╭────────────── Error ──────────────╮ "
" │ │ "
" │ Unable to exec into container │ "
" │ │ "
" │ ( c ) clear error │ "
" │ │ "
" │ ( F4 | End ) quit oxker │ "
" │ │ "
" ╰───────────────────────────────────╯ "
" "
@@ -0,0 +1,15 @@
---
source: src/ui/draw_blocks/error.rs
expression: setup.terminal.backend()
---
" "
" ╭────────────── Error ──────────────╮ "
" │ │ "
" │ Unable to exec into container │ "
" │ │ "
" │ ( Back Tab | m ) clear error │ "
" │ │ "
" │ ( F4 | End ) quit oxker │ "
" │ │ "
" ╰───────────────────────────────────╯ "
" "
@@ -0,0 +1,13 @@
---
source: src/ui/draw_blocks/error.rs
expression: setup.terminal.backend()
---
" "
"╭────────────────── Error ───────────────────╮"
"│ │"
"│ Unable to access docker daemon │"
"│ │"
"│ oxker::v0.10.0 closing in 04 seconds │"
"│ │"
"╰────────────────────────────────────────────╯"
" "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/filter.rs
expression: setup.terminal.backend()
---
" Esc clear ← by → Name Image Status All term: "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/filter.rs
expression: setup.terminal.backend()
---
" Esc clear ← by → Name Image Status All term: cd "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/filter.rs
expression: setup.terminal.backend()
---
" Esc clear ← by → Name Image Status All term: "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/filter.rs
expression: setup.terminal.backend()
---
" Esc clear ← by → Name Image Status All term: "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/filter.rs
expression: setup.terminal.backend()
---
" Esc clear ← by → Name Image Status All term: cd "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" ⠙ name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" ⠙ name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ↑ tx ( T ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ↑ tx ( T | Tab ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ↑ tx ( T | Tab ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" ( h ) exit help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" ( h ) exit help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu ▲ memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu ▼ memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id ▲ image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id ▼ image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ▲ ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ▼ ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit ▲ id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit ▼ id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name ▲ state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name ▼ state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ▲ ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ▼ ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state ▲ status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state ▼ status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status ▲ cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status ▼ cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ↑ tx ▲ ( h ) show help "
@@ -0,0 +1,5 @@
---
source: src/ui/draw_blocks/headers.rs
expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ↑ tx ▼ ( h ) show help "
@@ -0,0 +1,37 @@
---
source: src/ui/draw_blocks/help.rs
expression: setup.terminal.backend()
---
" "
" ╭ 0.10.0 ───────────────────────────────────────────────────────────────────────────╮ "
" │ │ "
" │ 88 │ "
" │ 88 │ "
" │ 88 │ "
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ "
" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "
" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "
" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "
" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "
" │ │ "
" │ A simple tui to view & control docker containers │ "
" │ │ "
" │ ( tab ) or ( shift+tab ) change panels │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ "
" │ ( enter ) send docker container command │ "
" │ ( e ) exec into a container │ "
" │ ( h ) toggle this help information - or click heading │ "
" │ ( s ) save logs to file │ "
" │ ( m ) toggle mouse capture - if disabled, text on screen can be selected & copied │ "
" │ ( F1 ) or ( / ) enter filter mode │ "
" │ ( 0 ) stop sort │ "
" │ ( 1 - 9 ) sort by header - or click header │ "
" │ ( esc ) close dialog │ "
" │ ( q ) quit at any time │ "
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" │ │ "
" ╰───────────────────────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,37 @@
---
source: src/ui/draw_blocks/help.rs
expression: setup.terminal.backend()
---
" "
" ╭ 0.10.0 ───────────────────────────────────────────────────────────────────────────╮ "
" │ │ "
" │ 88 │ "
" │ 88 │ "
" │ 88 │ "
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ "
" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "
" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "
" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "
" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "
" │ │ "
" │ A simple tui to view & control docker containers │ "
" │ │ "
" │ ( tab ) or ( shift+tab ) change panels │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ "
" │ ( enter ) send docker container command │ "
" │ ( e ) exec into a container │ "
" │ ( h ) toggle this help information - or click heading │ "
" │ ( s ) save logs to file │ "
" │ ( m ) toggle mouse capture - if disabled, text on screen can be selected & copied │ "
" │ ( F1 ) or ( / ) enter filter mode │ "
" │ ( 0 ) stop sort │ "
" │ ( 1 - 9 ) sort by header - or click header │ "
" │ ( esc ) close dialog │ "
" │ ( q ) quit at any time │ "
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" │ │ "
" ╰───────────────────────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,51 @@
---
source: src/ui/draw_blocks/help.rs
expression: setup.terminal.backend()
---
" "
" ╭ 0.10.0 ────────────────────────────────────────────────────────────────────────────────────╮ "
" │ │ "
" │ 88 │ "
" │ 88 │ "
" │ 88 │ "
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ "
" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "
" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "
" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "
" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "
" │ │ "
" │ A simple tui to view & control docker containers │ "
" │ │ "
" │ ( 0 ) select next panel │ "
" │ ( 2 ) select previous panel │ "
" │ ( q ) scroll list down by one │ "
" │ ( y ) scroll list up by one │ "
" │ ( o ) scroll list down by many │ "
" │ ( w ) scroll list by up many │ "
" │ ( s ) scroll list to end │ "
" │ ( u ) scroll list to start │ "
" │ ( enter ) send docker container command │ "
" │ ( g ) exec into a container │ "
" │ ( Home ) toggle this help information - or click heading │ "
" │ ( m ) save logs to file │ "
" │ ( Page Down ) toggle mouse capture - if disabled, text on screen can be selected & copied │ "
" │ ( i ) enter filter mode │ "
" │ ( Up ) reset container sorting │ "
" │ ( 4 ) sort containers by name │ "
" │ ( 6 ) sort containers by state │ "
" │ ( 8 ) sort containers by status │ "
" │ ( F1 ) sort containers by cpu │ "
" │ ( # ) sort containers by memory │ "
" │ ( / ) sort containers by id │ "
" │ ( , ) sort containers by image │ "
" │ ( . ) sort containers by rx │ "
" │ ( Backspace ) sort containers by tx │ "
" │ ( a ) close dialog │ "
" │ ( k ) quit at any time │ "
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" │ │ "
" ╰────────────────────────────────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,51 @@
---
source: src/ui/draw_blocks/help.rs
expression: setup.terminal.backend()
---
" "
" ╭ 0.10.0 ──────────────────────────────────────────────────────────────────────────────────────────────────╮ "
" │ │ "
" │ 88 │ "
" │ 88 │ "
" │ 88 │ "
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ "
" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "
" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "
" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "
" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "
" │ │ "
" │ A simple tui to view & control docker containers │ "
" │ │ "
" │ ( 0 ) or ( 1 ) select next panel │ "
" │ ( 2 ) or ( 3 ) select previous panel │ "
" │ ( q ) or ( r ) scroll list down by one │ "
" │ ( y ) or ( z ) scroll list up by one │ "
" │ ( o ) or ( p ) scroll list down by many │ "
" │ ( w ) or ( x ) scroll list by up many │ "
" │ ( s ) or ( t ) scroll list to end │ "
" │ ( u ) or ( v ) scroll list to start │ "
" │ ( enter ) send docker container command │ "
" │ ( g ) or ( h ) exec into a container │ "
" │ ( Home ) or ( Del ) toggle this help information - or click heading │ "
" │ ( m ) or ( n ) save logs to file │ "
" │ ( Page Down ) or ( Page Up ) toggle mouse capture - if disabled, text on screen can be selected & copied │ "
" │ ( i ) or ( j ) enter filter mode │ "
" │ ( Up ) or ( Down ) reset container sorting │ "
" │ ( 4 ) or ( 5 ) sort containers by name │ "
" │ ( 6 ) or ( 7 ) sort containers by state │ "
" │ ( 8 ) or ( 9 ) sort containers by status │ "
" │ ( F1 ) or ( F12 ) sort containers by cpu │ "
" │ ( # ) or ( - ) sort containers by memory │ "
" │ ( / ) or ( = ) sort containers by id │ "
" │ ( , ) or ( \ ) sort containers by image │ "
" │ ( . ) or ( ] ) sort containers by rx │ "
" │ ( Backspace ) or ( Back Tab ) sort containers by tx │ "
" │ ( a ) or ( b ) close dialog │ "
" │ ( k ) or ( l ) quit at any time │ "
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" │ │ "
" ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,51 @@
---
source: src/ui/draw_blocks/help.rs
expression: setup.terminal.backend()
---
" "
" ╭ 0.10.0 ──────────────────────────────────────────────────────────────────────────────────────────────────╮ "
" │ │ "
" │ 88 │ "
" │ 88 │ "
" │ 88 │ "
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ "
" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "
" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "
" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "
" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "
" │ │ "
" │ A simple tui to view & control docker containers │ "
" │ │ "
" │ ( 0 ) select next panel │ "
" │ ( 2 ) or ( 3 ) select previous panel │ "
" │ ( q ) or ( r ) scroll list down by one │ "
" │ ( y ) or ( z ) scroll list up by one │ "
" │ ( o ) scroll list down by many │ "
" │ ( w ) scroll list by up many │ "
" │ ( s ) scroll list to end │ "
" │ ( u ) or ( v ) scroll list to start │ "
" │ ( enter ) send docker container command │ "
" │ ( g ) exec into a container │ "
" │ ( Home ) toggle this help information - or click heading │ "
" │ ( m ) or ( n ) save logs to file │ "
" │ ( Page Down ) or ( Page Up ) toggle mouse capture - if disabled, text on screen can be selected & copied │ "
" │ ( i ) or ( j ) enter filter mode │ "
" │ ( Up ) or ( Down ) reset container sorting │ "
" │ ( 4 ) sort containers by name │ "
" │ ( 6 ) or ( 7 ) sort containers by state │ "
" │ ( 8 ) sort containers by status │ "
" │ ( F1 ) or ( F12 ) sort containers by cpu │ "
" │ ( # ) sort containers by memory │ "
" │ ( / ) or ( = ) sort containers by id │ "
" │ ( , ) sort containers by image │ "
" │ ( . ) or ( ] ) sort containers by rx │ "
" │ ( Backspace ) sort containers by tx │ "
" │ ( a ) or ( b ) close dialog │ "
" │ ( k ) quit at any time │ "
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" │ │ "
" ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ "
" "
@@ -0,0 +1,39 @@
---
source: src/ui/draw_blocks/help.rs
expression: setup.terminal.backend()
---
" "
" ╭ 0.10.0 ───────────────────────────────────────────────────────────────────────────╮ "
" │ │ "
" │ 88 │ "
" │ 88 │ "
" │ 88 │ "
" │ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │ "
" │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ "
" │ 8b d8 )888( 8888[ 8PP""""""" 88 │ "
" │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ "
" │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ "
" │ │ "
" │ A simple tui to view & control docker containers │ "
" │ │ "
" │ logs timezone: Asia/Tokyo │ "
" │ │ "
" │ ( tab ) or ( shift+tab ) change panels │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ "
" │ ( enter ) send docker container command │ "
" │ ( e ) exec into a container │ "
" │ ( h ) toggle this help information - or click heading │ "
" │ ( s ) save logs to file │ "
" │ ( m ) toggle mouse capture - if disabled, text on screen can be selected & copied │ "
" │ ( F1 ) or ( / ) enter filter mode │ "
" │ ( 0 ) stop sort │ "
" │ ( 1 - 9 ) sort by header - or click header │ "
" │ ( esc ) close dialog │ "
" │ ( q ) quit at any time │ "
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" │ │ "
" ╰───────────────────────────────────────────────────────────────────────────────────╯ "
" "

Some files were not shown because too many files have changed in this diff Show More