Monorepo consolidation: workspace, shared types, transport plans, docker/swam assets
This commit is contained in:
31
control/api/tests/swarm_client.rs
Normal file
31
control/api/tests/swarm_client.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
#[test]
|
||||
fn swarm_store_is_deterministic_from_file() {
|
||||
let mut path = std::env::temp_dir();
|
||||
path.push(format!(
|
||||
"cloudlysis-control-swarm-{}-{}.json",
|
||||
std::process::id(),
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
|
||||
fs::write(
|
||||
&path,
|
||||
r#"{"services":[{"name":"gateway","image":"x","mode":"replicated","replicas":"1/1","updated_at":null}],"tasks":[{"id":"t1","service":"gateway","node":"n1","desired_state":"running","current_state":"running","error":null}]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let store = api::SwarmStore::new(PathBuf::from(&path));
|
||||
let services = store.list_services();
|
||||
assert_eq!(services.len(), 1);
|
||||
assert_eq!(services[0].name, "gateway");
|
||||
|
||||
let tasks = store.list_tasks("gateway");
|
||||
assert_eq!(tasks.len(), 1);
|
||||
assert_eq!(tasks[0].id, "t1");
|
||||
|
||||
let none = store.list_tasks("missing");
|
||||
assert_eq!(none.len(), 0);
|
||||
|
||||
let _ = fs::remove_file(&path);
|
||||
}
|
||||
Reference in New Issue
Block a user