tangled
alpha
login
or
join now
althaea.zone
/
wire
3
fork
atom
ALPHA: wire is a tool to deploy nixos systems
wire.althaea.zone/
3
fork
atom
overview
issues
pulls
pipelines
add test for Target
marshmallow
4 months ago
40323393
9824aac4
+47
-1
1 changed file
expand all
collapse all
unified
split
wire
lib
src
hive
node.rs
+47
-1
wire/lib/src/hive/node.rs
···
453
453
hive::{Hive, get_hive_location},
454
454
location,
455
455
};
456
456
-
use std::path::PathBuf;
456
456
+
use std::{assert_matches::assert_matches, path::PathBuf};
457
457
use std::{collections::HashMap, env};
458
458
459
459
fn get_steps(goal_executor: GoalExecutor) -> std::vec::Vec<Step> {
···
628
628
CleanUp.into()
629
629
]
630
630
);
631
631
+
}
632
632
+
633
633
+
#[test]
634
634
+
fn target_fails_increments() {
635
635
+
let mut target = Target::from_host("localhost");
636
636
+
637
637
+
assert_eq!(target.current_host, 0);
638
638
+
639
639
+
for i in 0..100 {
640
640
+
target.host_failed();
641
641
+
assert_eq!(target.current_host, i + 1);
642
642
+
}
643
643
+
}
644
644
+
645
645
+
#[test]
646
646
+
fn get_preferred_host_fails() {
647
647
+
let mut target = Target {
648
648
+
hosts: vec![
649
649
+
"un.reachable.1".into(),
650
650
+
"un.reachable.2".into(),
651
651
+
"un.reachable.3".into(),
652
652
+
"un.reachable.4".into(),
653
653
+
"un.reachable.5".into(),
654
654
+
],
655
655
+
..Default::default()
656
656
+
};
657
657
+
658
658
+
assert_ne!(
659
659
+
target.get_preferred_host().unwrap().to_string(),
660
660
+
"un.reachable.5"
661
661
+
);
662
662
+
663
663
+
for i in 1..=5 {
664
664
+
assert_eq!(
665
665
+
target.get_preferred_host().unwrap().to_string(),
666
666
+
format!("un.reachable.{i}")
667
667
+
);
668
668
+
target.host_failed();
669
669
+
}
670
670
+
671
671
+
for _ in 0..5 {
672
672
+
assert_matches!(
673
673
+
target.get_preferred_host(),
674
674
+
Err(HiveLibError::NetworkError(NetworkError::HostsExhausted))
675
675
+
);
676
676
+
}
631
677
}
632
678
}