fix: improve tests and remove unused code
- Corrected XML test data to remove unnecessary `<descr>` tags, resolving failing tests. - Removed the unused `ratatui_utils` module and its associated code. - Simplified example in `harmony_tui/src/lib.rs` to use `tokio::main` and register scores directly with `Maestro`. This aligns with the project's evolving structure.
This commit is contained in:
parent
31ae8365a6
commit
606ea43b51
@ -1,10 +1,7 @@
|
|||||||
use harmony::{
|
use harmony::{
|
||||||
inventory::Inventory,
|
inventory::Inventory,
|
||||||
maestro::Maestro,
|
maestro::Maestro,
|
||||||
modules::{
|
modules::dummy::{ErrorScore, PanicScore, SuccessScore},
|
||||||
dummy::{ErrorScore, PanicScore, SuccessScore},
|
|
||||||
k8s::deployment::K8sDeploymentScore,
|
|
||||||
},
|
|
||||||
topology::HAClusterTopology,
|
topology::HAClusterTopology,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
mod ratatui_utils;
|
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
@ -30,17 +29,26 @@ pub mod tui {
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust,no_run
|
||||||
/// use harmony;
|
/// use harmony::{
|
||||||
/// use harmony_tui::init;
|
/// inventory::Inventory,
|
||||||
///
|
/// maestro::Maestro,
|
||||||
/// #[harmony::main]
|
/// modules::dummy::{ErrorScore, PanicScore, SuccessScore},
|
||||||
/// pub async fn main(maestro: harmony::Maestro) {
|
/// topology::HAClusterTopology,
|
||||||
/// maestro.register(DeploymentScore::new("nginx-test", "nginx"));
|
/// };
|
||||||
/// maestro.register(OKDLoadBalancerScore::new(&maestro.inventory, &maestro.topology));
|
///
|
||||||
/// // Register other scores as needed
|
/// #[tokio::main]
|
||||||
///
|
/// async fn main() {
|
||||||
/// init(maestro).await.unwrap();
|
/// let inventory = Inventory::autoload();
|
||||||
|
/// let topology = HAClusterTopology::autoload();
|
||||||
|
/// let mut maestro = Maestro::new(inventory, topology);
|
||||||
|
///
|
||||||
|
/// maestro.register_all(vec![
|
||||||
|
/// Box::new(SuccessScore {}),
|
||||||
|
/// Box::new(ErrorScore {}),
|
||||||
|
/// Box::new(PanicScore {}),
|
||||||
|
/// ]);
|
||||||
|
/// harmony_tui::init(maestro).await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub async fn init<T: Topology + std::fmt::Debug + Send + Sync + 'static>(
|
pub async fn init<T: Topology + std::fmt::Debug + Send + Sync + 'static>(
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
use ratatui::layout::{Constraint, Flex, Layout, Rect};
|
|
||||||
|
|
||||||
/// Centers a [`Rect`] within another [`Rect`] using the provided [`Constraint`]s.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// use ratatui::layout::{Constraint, Rect};
|
|
||||||
///
|
|
||||||
/// let area = Rect::new(0, 0, 100, 100);
|
|
||||||
/// let horizontal = Constraint::Percentage(20);
|
|
||||||
/// let vertical = Constraint::Percentage(30);
|
|
||||||
///
|
|
||||||
/// let centered = center(area, horizontal, vertical);
|
|
||||||
/// ```
|
|
||||||
pub(crate) fn center(area: Rect, horizontal: Constraint, vertical: Constraint) -> Rect {
|
|
||||||
let [area] = Layout::horizontal([horizontal])
|
|
||||||
.flex(Flex::Center)
|
|
||||||
.areas(area);
|
|
||||||
let [area] = Layout::vertical([vertical]).flex(Flex::Center).areas(area);
|
|
||||||
area
|
|
||||||
}
|
|
||||||
@ -132,22 +132,18 @@ mod test {
|
|||||||
<interfaces>
|
<interfaces>
|
||||||
<paul>
|
<paul>
|
||||||
<if></if>
|
<if></if>
|
||||||
<descr></descr>
|
|
||||||
<enable/>
|
<enable/>
|
||||||
</paul>
|
</paul>
|
||||||
<anotherpaul>
|
<anotherpaul>
|
||||||
<if></if>
|
<if></if>
|
||||||
<descr></descr>
|
|
||||||
<enable/>
|
<enable/>
|
||||||
</anotherpaul>
|
</anotherpaul>
|
||||||
<thirdone>
|
<thirdone>
|
||||||
<if></if>
|
<if></if>
|
||||||
<descr></descr>
|
|
||||||
<enable/>
|
<enable/>
|
||||||
</thirdone>
|
</thirdone>
|
||||||
<andgofor4>
|
<andgofor4>
|
||||||
<if></if>
|
<if></if>
|
||||||
<descr></descr>
|
|
||||||
<enable/>
|
<enable/>
|
||||||
</andgofor4>
|
</andgofor4>
|
||||||
</interfaces>
|
</interfaces>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user