tests: AppData tests
This commit is contained in:
@@ -60,6 +60,13 @@ macro_rules! unit_struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
impl From<&str> for $name {
|
||||||
|
fn from(value: &str) -> Self {
|
||||||
|
Self(value.to_owned())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl$name {
|
impl$name {
|
||||||
pub fn get(&self) -> &str {
|
pub fn get(&self) -> &str {
|
||||||
self.0.as_str()
|
self.0.as_str()
|
||||||
@@ -93,7 +100,7 @@ macro_rules! unit_struct {
|
|||||||
unit_struct!(ContainerName);
|
unit_struct!(ContainerName);
|
||||||
unit_struct!(ContainerImage);
|
unit_struct!(ContainerImage);
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct StatefulList<T> {
|
pub struct StatefulList<T> {
|
||||||
pub state: ListState,
|
pub state: ListState,
|
||||||
pub items: Vec<T>,
|
pub items: Vec<T>,
|
||||||
@@ -234,7 +241,7 @@ impl fmt::Display for State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Items for the container control list
|
/// Items for the container control list
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum DockerControls {
|
pub enum DockerControls {
|
||||||
Pause,
|
Pause,
|
||||||
Restart,
|
Restart,
|
||||||
@@ -416,7 +423,7 @@ impl fmt::Display for LogsTz {
|
|||||||
/// Store the logs alongside a HashSet, each log *should* generate a unique timestamp,
|
/// Store the logs alongside a HashSet, each log *should* generate a unique timestamp,
|
||||||
/// so if we store the timestamp separately in a HashSet, we can then check if we should insert a log line into the
|
/// so if we store the timestamp separately in a HashSet, we can then check if we should insert a log line into the
|
||||||
/// stateful list dependent on whethere the timestamp is in the HashSet or not
|
/// stateful list dependent on whethere the timestamp is in the HashSet or not
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Logs {
|
pub struct Logs {
|
||||||
logs: StatefulList<ListItem<'static>>,
|
logs: StatefulList<ListItem<'static>>,
|
||||||
tz: HashSet<LogsTz>,
|
tz: HashSet<LogsTz>,
|
||||||
@@ -475,7 +482,7 @@ impl Logs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Info for each container
|
/// Info for each container
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct ContainerItem {
|
pub struct ContainerItem {
|
||||||
pub created: u64,
|
pub created: u64,
|
||||||
pub cpu_stats: VecDeque<CpuStats>,
|
pub cpu_stats: VecDeque<CpuStats>,
|
||||||
@@ -594,7 +601,7 @@ impl ContainerItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Container information panel headings + widths, for nice pretty formatting
|
/// Container information panel headings + widths, for nice pretty formatting
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct Columns {
|
pub struct Columns {
|
||||||
pub name: (Header, u8),
|
pub name: (Header, u8),
|
||||||
pub state: (Header, u8),
|
pub state: (Header, u8),
|
||||||
|
|||||||
+1282
-129
File diff suppressed because it is too large
Load Diff
@@ -150,7 +150,7 @@ impl DockerData {
|
|||||||
|
|
||||||
app_data
|
app_data
|
||||||
.lock()
|
.lock()
|
||||||
.update_stats(&id, cpu_stats, mem_stat, mem_limit, rx, tx);
|
.update_stats_by_id(&id, cpu_stats, mem_stat, mem_limit, rx, tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spawns.lock().remove(&spawn_id);
|
spawns.lock().remove(&spawn_id);
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ impl InputHandler {
|
|||||||
// This isn't great, just means you can't send docker commands before full initialization of the program
|
// This isn't great, just means you can't send docker commands before full initialization of the program
|
||||||
let panel = self.gui_state.lock().get_selected_panel();
|
let panel = self.gui_state.lock().get_selected_panel();
|
||||||
if panel == SelectablePanel::Commands {
|
if panel == SelectablePanel::Commands {
|
||||||
let option_command = self.app_data.lock().selected_docker_command();
|
let option_command = self.app_data.lock().selected_docker_controls();
|
||||||
|
|
||||||
if let Some(command) = option_command {
|
if let Some(command) = option_command {
|
||||||
// Poor way of disallowing commands to be sent to a containerised okxer
|
// Poor way of disallowing commands to be sent to a containerised okxer
|
||||||
@@ -337,7 +337,7 @@ impl InputHandler {
|
|||||||
match selected_panel {
|
match selected_panel {
|
||||||
SelectablePanel::Containers => locked_data.containers_start(),
|
SelectablePanel::Containers => locked_data.containers_start(),
|
||||||
SelectablePanel::Logs => locked_data.log_start(),
|
SelectablePanel::Logs => locked_data.log_start(),
|
||||||
SelectablePanel::Commands => locked_data.docker_command_start(),
|
SelectablePanel::Commands => locked_data.docker_controls_start(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ impl InputHandler {
|
|||||||
match selected_panel {
|
match selected_panel {
|
||||||
SelectablePanel::Containers => locked_data.containers_end(),
|
SelectablePanel::Containers => locked_data.containers_end(),
|
||||||
SelectablePanel::Logs => locked_data.log_end(),
|
SelectablePanel::Logs => locked_data.log_end(),
|
||||||
SelectablePanel::Commands => locked_data.docker_command_end(),
|
SelectablePanel::Commands => locked_data.docker_controls_end(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,7 +481,7 @@ impl InputHandler {
|
|||||||
match selected_panel {
|
match selected_panel {
|
||||||
SelectablePanel::Containers => locked_data.containers_next(),
|
SelectablePanel::Containers => locked_data.containers_next(),
|
||||||
SelectablePanel::Logs => locked_data.log_next(),
|
SelectablePanel::Logs => locked_data.log_next(),
|
||||||
SelectablePanel::Commands => locked_data.docker_command_next(),
|
SelectablePanel::Commands => locked_data.docker_controls_next(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ impl InputHandler {
|
|||||||
match selected_panel {
|
match selected_panel {
|
||||||
SelectablePanel::Containers => locked_data.containers_previous(),
|
SelectablePanel::Containers => locked_data.containers_previous(),
|
||||||
SelectablePanel::Logs => locked_data.log_previous(),
|
SelectablePanel::Logs => locked_data.log_previous(),
|
||||||
SelectablePanel::Commands => locked_data.docker_command_previous(),
|
SelectablePanel::Commands => locked_data.docker_controls_previous(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user