tests: updated tests

This commit is contained in:
Jack Wills
2026-01-25 09:33:08 +00:00
parent 4b7bf38a3f
commit 307810391c
24 changed files with 243 additions and 233 deletions
+4 -2
View File
@@ -45,6 +45,9 @@ tracing = "0.1"
tracing-subscriber = "0.3"
uuid = { version = "1.19", features = ["fast-rng", "v4"] }
[dev-dependencies]
insta = "1.42.2"
[profile.release]
lto = true
codegen-units = 1
@@ -52,5 +55,4 @@ panic = 'abort'
strip = true
debug = false
[dev-dependencies]
insta = "1.42.2"
+4 -2
View File
@@ -173,7 +173,8 @@ impl AppData {
pub fn log_search_scroll(&mut self, np: &ScrollDirection) {
if let Some(i) = self.get_mut_selected_container()
&& i.logs.search_scroll(np).is_some() {
&& i.logs.search_scroll(np).is_some()
{
self.rerender.update_draw();
}
}
@@ -340,7 +341,8 @@ impl AppData {
pub fn set_sort_by_header(&mut self, selected_header: Header) {
let mut output = Some((selected_header, SortedOrder::Asc));
if let Some((current_header, order)) = self.get_sorted()
&& current_header == selected_header {
&& current_header == selected_header
{
match order {
SortedOrder::Desc => output = None,
SortedOrder::Asc => output = Some((selected_header, SortedOrder::Desc)),
+4 -2
View File
@@ -159,7 +159,8 @@ impl From<Option<ConfigKeymap>> for Keymap {
keymap_field: &mut (KeyCode, Option<KeyCode>),
keymap_clash: &mut HashSet<KeyCode>| {
if let Some(vec_str) = vec_str
&& let Some(vec_keycode) = Self::try_parse_keycode(&vec_str) {
&& let Some(vec_keycode) = Self::try_parse_keycode(&vec_str)
{
if let Some(first) = vec_keycode.first() {
keymap_clash.insert(*first);
counter += 1;
@@ -282,7 +283,8 @@ impl Keymap {
Some(first_char)
}
_ => None,
} {
}
{
output.push(KeyCode::Char(first_char));
}
} else {
+7 -7
View File
@@ -168,7 +168,8 @@ impl ExecMode {
]
.contains(&state)
{
if tty_readable() && !use_cli
if tty_readable()
&& !use_cli
&& let Ok(exec) = docker
.create_exec(
id.get(),
@@ -183,18 +184,17 @@ impl ExecMode {
&& let Ok(StartExecResults::Attached { mut output, .. }) =
docker.start_exec(&exec.id, None).await
&& let Some(Ok(msg)) = output.next().await
&& !msg.to_string().starts_with(OCI_ERROR) {
return Some(Self::Internal((
Arc::new(id),
Arc::clone(docker),
)));
&& !msg.to_string().starts_with(OCI_ERROR)
{
return Some(Self::Internal((Arc::new(id), Arc::clone(docker))));
}
if let Ok(output) = std::process::Command::new(command::DOCKER)
.args([command::EXEC, id.get(), command::PWD])
.output()
&& let Ok(output) = String::from_utf8(output.stdout)
&& !output.starts_with(OCI_ERROR) {
&& !output.starts_with(OCI_ERROR)
{
return Some(Self::External(Arc::new(id)));
}
}
+2 -1
View File
@@ -179,7 +179,8 @@ impl InputHandler {
let args = self.app_data.lock().config.clone();
let container = self.app_data.lock().get_selected_container_id_state_name();
if let Some((id, _, name)) = container
&& let Some(log_path) = args.save_dir {
&& let Some(log_path) = args.save_dir
{
let (sx, rx) = tokio::sync::oneshot::channel();
self.docker_tx.send(DockerMessage::Exec(sx)).await?;
+19 -19
View File
@@ -194,42 +194,41 @@ mod tests {
];
// co-ordinates of the dots from the cpu chart
const CPU_XY: [(usize, usize); 15] = [
(1, 12),
(2, 11),
const CPU_XY: [(usize, usize); 16] = [
(1, 13),
(2, 12),
(3, 10),
(2, 13),
(3, 11),
(3, 12),
(4, 10),
(4, 12),
(5, 9),
(3, 13),
(4, 11),
(4, 13),
(5, 10),
(5, 13),
(5, 14),
(6, 8),
(6, 9),
(6, 13),
(6, 14),
(7, 8),
(7, 9),
(7, 13),
(7, 14),
];
// co-ordinates of the dots from the memory chart
const MEM_XY: [(usize, usize); 16] = [
(1, 54),
const MEM_XY: [(usize, usize); 14] = [
(1, 55),
(2, 54),
(2, 55),
(3, 53),
(3, 54),
(3, 55),
(4, 52),
(4, 53),
(4, 55),
(5, 51),
(5, 52),
(5, 55),
(5, 53),
(5, 56),
(6, 51),
(6, 55),
(6, 52),
(6, 56),
(7, 51),
(7, 55),
(7, 56),
];
#[test]
@@ -336,6 +335,7 @@ mod tests {
.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() {
+2 -1
View File
@@ -40,7 +40,8 @@ fn gen_header_block<'a>(colors: AppColors, fd: &FrameData, header: Header) -> (C
let mut color = colors.headers_bar.text;
let mut suffix = "";
if let Some((a, b)) = &fd.sorted_by
&& &header == a {
&& &header == a
{
match b {
SortedOrder::Asc => suffix = "",
SortedOrder::Desc => suffix = "",
+2 -1
View File
@@ -104,7 +104,8 @@ fn generate_block<'a>(
.title(ratatui::text::Line::from(title).left_aligned());
if panel == SelectablePanel::Logs
&& let Some(x) = fd.scroll_title.as_ref() {
&& let Some(x) = fd.scroll_title.as_ref()
{
block = block
.title_bottom(x.to_owned())
.title_alignment(ratatui::layout::Alignment::Right);
@@ -3,12 +3,12 @@ source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮"
"│10.00%│ • ││100.00 kB│ • │"
"│10.00%│ • ││100.00 kB│ • │"
"│ │ •• ││ │ •• │"
"│ │ ••• ││ │ • • │"
"│ │ ││ │ •• │"
"│ │ • • ││ │ • • │"
"│ │ • • ││ │•• • │"
"│ │• ││ │• • │"
"│ │• ││ │• • │"
"│ │ • • ││ │ •• • │"
"│ │ •• ││ │ • • │"
"│ │• ││ │• • │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -3,12 +3,12 @@ source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮"
"│10.00%│ • ││100.00 kB│ • │"
"│10.00%│ • ││100.00 kB│ • │"
"│ │ •• ││ │ •• │"
"│ │ ••• ││ │ • • │"
"│ │ ││ │ •• │"
"│ │ • • ││ │ • • │"
"│ │ • • ││ │•• • │"
"│ │• ││ │• • │"
"│ │• ││ │• • │"
"│ │ • • ││ │ •• • │"
"│ │ •• ││ │ • • │"
"│ │• ││ │• • │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -3,12 +3,12 @@ source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮"
"│10.00%│ • ││100.00 kB│ • │"
"│10.00%│ • ││100.00 kB│ • │"
"│ │ •• ││ │ •• │"
"│ │ ••• ││ │ • • │"
"│ │ ││ │ •• │"
"│ │ • • ││ │ • • │"
"│ │ • • ││ │•• • │"
"│ │• ││ │• • │"
"│ │• ││ │• • │"
"│ │ • • ││ │ •• • │"
"│ │ •• ││ │ • • │"
"│ │• ││ │• • │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -3,12 +3,12 @@ source: src/ui/draw_blocks/charts.rs
expression: setup.terminal.backend()
---
"╭───────────── cpu 03.00% ─────────────╮╭────────── memory 30.00 kB ───────────╮"
"│10.00%│ • ││100.00 kB│ • │"
"│10.00%│ • ││100.00 kB│ • │"
"│ │ •• ││ │ •• │"
"│ │ ••• ││ │ • • │"
"│ │ ││ │ •• │"
"│ │ • • ││ │ • • │"
"│ │ • • ││ │•• • │"
"│ │• ││ │• • │"
"│ │• ││ │• • │"
"│ │ • • ││ │ •• • │"
"│ │ •• ││ │ • • │"
"│ │• ││ │• • │"
"│ │ ││ │ │"
"╰──────────────────────────────────────╯╰──────────────────────────────────────╯"
@@ -26,9 +26,9 @@ expression: setup.terminal.backend()
"│ │"
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮"
"│10.00%│ •• ││100.00 kB│ •• ││ ip private public│"
"│ │ • • ││ │ •• • ││ 8001 │"
"│ │ ••• • • ││ │ •• ││127.0.0.1 8003 8003│"
"│ │• •• ││ │• •• ││ │"
"│ │ ││ │ ││ │"
"│10.00%│ •• ││100.00 kB│ •• ││ ip private public│"
"│ │ • • ││ │ •• • ││ 8001 │"
"│ │ ••• ││ │ •• • ││127.0.0.1 8003 8003│"
"│ │• •• ││ │• •• ││ │"
"│ │ ││ │ ││ │"
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
@@ -33,12 +33,12 @@ expression: setup.terminal.backend()
"│ │"
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮"
"│10.00%│ • ││100.00 kB│ • ││ ip private public│"
"│ │ • • ││ │ •• ││ 8001 │"
"│ │ • • ││ │ •• • ││127.0.0.1 8003 8003│"
"│10.00%│ • ││100.00 kB│ • ││ ip private public│"
"│ │ •• ││ │ •• ││ 8001 │"
"│ │ • • ││ │ • ││127.0.0.1 8003 8003│"
"│ │ • • ││ │ • • ││ │"
"│ │ •• ││ │ • • ││ │"
"│ │• • ││ │• •• ││ │"
"│ │• ││ │• • ││ │"
"│ │ •• • ││ │ • • ││ │"
"│ │ • • ││ │ • •• ││ │"
"│ │• ││ │• ││ │"
"│ │ ││ │ ││ │"
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
@@ -33,12 +33,12 @@ expression: setup.terminal.backend()
"│ │"
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮"
"│10.00%│ • ││100.00 kB│ • ││ ip private public│"
"│ │ • • ││ │ •• ││ 8001 │"
"│ │ • • ││ │ •• • ││127.0.0.1 8003 8003│"
"│10.00%│ • ││100.00 kB│ • ││ ip private public│"
"│ │ •• ││ │ •• ││ 8001 │"
"│ │ • • ││ │ • ││127.0.0.1 8003 8003│"
"│ │ • • ││ │ • • ││ │"
"│ │ •• ││ │ • • ││ │"
"│ │• • ││ │• •• ││ │"
"│ │• ││ │• • ││ │"
"│ │ •• • ││ │ • • ││ │"
"│ │ • • ││ │ • •• ││ │"
"│ │• ││ │• ││ │"
"│ │ ││ │ ││ │"
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
@@ -33,12 +33,12 @@ expression: setup.terminal.backend()
"│ │ ( 1 - 9 ) sort by header - or click header │ │"
"╰────────────────────────────────────│ ( - = ) change log section height │────────────────────────────────────╯"
"╭───────────────────────── cpu 03.00%│ ( \ ) toggle log section visibility │──────╮╭────────── ports ───────────╮"
"│10.00%│ • │ ( esc ) close dialog │ ││ ip private public│"
"│ │ • • │ ( q ) quit at any time │ ││ 8001 │"
"│ │ • • │ │ ││127.0.0.1 8003 8003│"
"│10.00%│ • │ ( esc ) close dialog │ ││ ip private public│"
"│ │ •• │ ( q ) quit at any time │ ││ 8001 │"
"│ │ • • │ │ ││127.0.0.1 8003 8003│"
"│ │ • • │ currently an early work in progress, all and any input appreciated │ ││ │"
"│ │ •• │ https://github.com/mrjackwills/oxker │ ││ │"
"│ │• • │ │ ││ │"
"│ │• ╰────────────────────────────────────────────────────────────────────────────────────╯ ││ │"
"│ │ •• • │ https://github.com/mrjackwills/oxker │ ││ │"
"│ │ • • │ │ ││ │"
"│ │• ╰────────────────────────────────────────────────────────────────────────────────────╯ ││ │"
"│ │ ││ │ ││ │"
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
@@ -33,12 +33,12 @@ expression: setup.terminal.backend()
"│ │"
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮"
"│10.00%│ • ││100.00 kB│ • ││ ip private public│"
"│ │ • • ││ │ •• ││ 8001 │"
"│ │ • • ││ │ •• • ││127.0.0.1 8003 8003│"
"│10.00%│ • ││100.00 kB│ • ││ ip private public│"
"│ │ •• ││ │ •• ││ 8001 │"
"│ │ • • ││ │ • ││127.0.0.1 8003 8003│"
"│ │ • • ││ │ • • ││ │"
"│ │ •• ││ │ • • ││ │"
"│ │• • ││ │• •• ││ "
"│ │• ││ │• • ││ This is a test "
"│ │ •• • ││ │ • • ││ │"
"│ │ • • ││ │ • •• ││ "
"│ │• ││ │• ││ This is a test "
"│ │ ││ │ ││ "
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰─────── "
@@ -26,9 +26,9 @@ expression: setup.terminal.backend()
"│ │"
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
"╭───────────────────────────────── cpu 03.00% ─────────────────────────────────╮╭────────────────────────────── memory 30.00 kB ───────────────────────────────╮╭────────── ports ───────────╮"
"│10.00%│ ••• ││100.00 kB│ •••• ││ ip private public│"
"│ │ •• • ││ │ •• • ││ 8001 │"
"│ │ ••• ││ │ ••• • • ││127.0.0.1 8003 8003│"
"│ │•• ••• ││ │•• •• ││ │"
"│ │ ││ │ ││ │"
"│10.00%│ ••• ││100.00 kB│ •• ││ ip private public│"
"│ │ •• • ││ │ •• • ││ 8001 │"
"│ │ ••• • ││ │ ••• ││127.0.0.1 8003 8003│"
"│ │•• ••• ││ │ •• •• ││ │"
"│ │ ││ │ ││ │"
"╰──────────────────────────────────────────────────────────────────────────────╯╰──────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
@@ -26,9 +26,9 @@ expression: setup.terminal.backend()
"│ ││ │"
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯╰──────────────╯"
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮"
"│10.00%│ •• ││100.00 kB│ •• ││ ip private public│"
"│ │ • • ││ │ •• • ││ 8001 │"
"│ │ ••• • • ││ │ •• ││127.0.0.1 8003 8003│"
"│ │• •• ││ │• •• ││ │"
"│ │ ││ │ ││ │"
"│10.00%│ •• ││100.00 kB│ •• ││ ip private public│"
"│ │ • • ││ │ •• • ││ 8001 │"
"│ │ ••• ││ │ •• • ││127.0.0.1 8003 8003│"
"│ │• •• ││ │• •• ││ │"
"│ │ ││ │ ││ │"
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
@@ -26,9 +26,9 @@ expression: setup.terminal.backend()
"│▶ 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│"
"│ │• •• ││ │• •• ││ │"
"│ │ ││ │ ││ │"
"│10.00%│ •• ││100.00 kB│ •• ││ ip private public│"
"│ │ • • ││ │ •• • ││ 8001 │"
"│ │ ••• ││ │ •• • ││127.0.0.1 8003 8003│"
"│ │• •• ││ │• •• ││ │"
"│ │ ││ │ ││ │"
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
@@ -25,10 +25,10 @@ expression: setup.terminal.backend()
"│ │"
"╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
"╭───────────────────────── cpu 03.00% ──────────────────────────╮╭─────────────────────── memory 30.00 kB ───────────────────────╮╭────────── ports ───────────╮"
"│10.00%│ •• ││100.00 kB│ •• ││ ip private public│"
"│ │ • • ││ │ •• • ││ 8001 │"
"│ │ ••• • • ││ │ •• ││ │"
"│ │• •• ││ │• •• ││ │"
"│ │ ││ │ ││ │"
"│10.00%│ •• ││100.00 kB│ •• ││ ip private public│"
"│ │ • • ││ │ •• • ││ 8001 │"
"│ │ ••• ││ │ •• • ││ │"
"│ │• •• ││ │• •• ││ │"
"│ │ ││ │ ││ │"
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
" Esc clear ← by → Name Image Status All filter term: r_1 "
+2 -1
View File
@@ -238,7 +238,8 @@ impl Ui {
}
if crossterm::event::poll(POLL_RATE).unwrap_or(false)
&& let Ok(event) = event::read() {
&& let Ok(event) = event::read()
{
if let Event::Key(key) = event {
if key.kind == event::KeyEventKind::Press {
self.input_tx