mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-03-31 16:23:08 +00:00
Add source orchestration contract tests
This commit is contained in:
parent
6405d31ebd
commit
feeafa4eaf
@ -69,7 +69,19 @@ impl SourceOrchestrationPlan {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{SourceOrchestrationMode, SourceOrchestrationPlan};
|
use super::{SourceOrchestrationMode, SourceOrchestrationPlan};
|
||||||
use crate::scenario::{ExistingCluster, sources::ScenarioSources};
|
use crate::scenario::{ExistingCluster, ExternalNodeSource, sources::ScenarioSources};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn managed_sources_are_planned() {
|
||||||
|
let plan = SourceOrchestrationPlan::try_from_sources(&ScenarioSources::default())
|
||||||
|
.expect("managed sources should build a source orchestration plan");
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
plan.mode(),
|
||||||
|
SourceOrchestrationMode::Managed { .. }
|
||||||
|
));
|
||||||
|
assert!(plan.external_sources().is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn attached_sources_are_planned() {
|
fn attached_sources_are_planned() {
|
||||||
@ -86,6 +98,46 @@ mod tests {
|
|||||||
SourceOrchestrationMode::Attached { .. }
|
SourceOrchestrationMode::Attached { .. }
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn attached_sources_keep_external_nodes() {
|
||||||
|
let sources = ScenarioSources::default()
|
||||||
|
.with_attach(ExistingCluster::for_compose_project(
|
||||||
|
"test-project".to_string(),
|
||||||
|
))
|
||||||
|
.with_external_node(ExternalNodeSource::new(
|
||||||
|
"external-0".to_owned(),
|
||||||
|
"http://127.0.0.1:1".to_owned(),
|
||||||
|
));
|
||||||
|
let plan = SourceOrchestrationPlan::try_from_sources(&sources)
|
||||||
|
.expect("attached sources with external nodes should build");
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
plan.mode(),
|
||||||
|
SourceOrchestrationMode::Attached { .. }
|
||||||
|
));
|
||||||
|
assert_eq!(plan.external_sources().len(), 1);
|
||||||
|
assert_eq!(plan.external_sources()[0].label(), "external-0");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn external_only_sources_are_planned() {
|
||||||
|
let sources = ScenarioSources::default()
|
||||||
|
.with_external_node(ExternalNodeSource::new(
|
||||||
|
"external-0".to_owned(),
|
||||||
|
"http://127.0.0.1:1".to_owned(),
|
||||||
|
))
|
||||||
|
.into_external_only();
|
||||||
|
let plan = SourceOrchestrationPlan::try_from_sources(&sources)
|
||||||
|
.expect("external-only sources should build a source orchestration plan");
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
plan.mode(),
|
||||||
|
SourceOrchestrationMode::ExternalOnly { .. }
|
||||||
|
));
|
||||||
|
assert_eq!(plan.external_sources().len(), 1);
|
||||||
|
assert_eq!(plan.external_sources()[0].label(), "external-0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mode_from_sources(sources: &ScenarioSources) -> SourceOrchestrationMode {
|
fn mode_from_sources(sources: &ScenarioSources) -> SourceOrchestrationMode {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user