use cellos_ctl::model::Formation;
#[test]
fn formation_deserialises_server_status_field_via_alias() {
let body = serde_json::json!({
"id": "f-1",
"name": "ctr",
"status": "RUNNING",
});
let f: Formation = serde_json::from_value(body).expect("alias must deserialise");
assert_eq!(
f.state, "RUNNING",
"alias `status` must populate the `state` field"
);
}
#[test]
fn formation_deserialises_canonical_state_field() {
let body = serde_json::json!({
"id": "f-2",
"name": "ctr2",
"state": "RUNNING",
});
let f: Formation = serde_json::from_value(body).expect("state field must deserialise");
assert_eq!(f.state, "RUNNING");
}
#[test]
fn formation_with_neither_field_defaults_to_empty_state() {
let body = serde_json::json!({
"id": "f-3",
"name": "ctr3",
});
let f: Formation = serde_json::from_value(body).expect("missing field uses default");
assert_eq!(f.state, "", "missing state/status must default to empty");
}