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::{
|
||||
inventory::Inventory,
|
||||
maestro::Maestro,
|
||||
modules::{
|
||||
dummy::{ErrorScore, PanicScore, SuccessScore},
|
||||
k8s::deployment::K8sDeploymentScore,
|
||||
},
|
||||
modules::dummy::{ErrorScore, PanicScore, SuccessScore},
|
||||
topology::HAClusterTopology,
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
mod ratatui_utils;
|
||||
mod widget;
|
||||
|
||||
use log::{debug, error, info};
|
||||
@ -30,17 +29,26 @@ pub mod tui {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use harmony;
|
||||
/// use harmony_tui::init;
|
||||
///
|
||||
/// #[harmony::main]
|
||||
/// pub async fn main(maestro: harmony::Maestro) {
|
||||
/// maestro.register(DeploymentScore::new("nginx-test", "nginx"));
|
||||
/// maestro.register(OKDLoadBalancerScore::new(&maestro.inventory, &maestro.topology));
|
||||
/// // Register other scores as needed
|
||||
///
|
||||
/// init(maestro).await.unwrap();
|
||||
/// ```rust,no_run
|
||||
/// use harmony::{
|
||||
/// inventory::Inventory,
|
||||
/// maestro::Maestro,
|
||||
/// modules::dummy::{ErrorScore, PanicScore, SuccessScore},
|
||||
/// topology::HAClusterTopology,
|
||||
/// };
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
/// 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>(
|
||||
|
@ -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>
|
||||
<paul>
|
||||
<if></if>
|
||||
<descr></descr>
|
||||
<enable/>
|
||||
</paul>
|
||||
<anotherpaul>
|
||||
<if></if>
|
||||
<descr></descr>
|
||||
<enable/>
|
||||
</anotherpaul>
|
||||
<thirdone>
|
||||
<if></if>
|
||||
<descr></descr>
|
||||
<enable/>
|
||||
</thirdone>
|
||||
<andgofor4>
|
||||
<if></if>
|
||||
<descr></descr>
|
||||
<enable/>
|
||||
</andgofor4>
|
||||
</interfaces>
|
||||
|
Loading…
Reference in New Issue
Block a user