use serde_json::json;
use super::{ADDRESS, ENROLL, enroll};
#[test]
fn an_enrollment_that_states_no_route_carries_no_address_field() {
let gesture = enroll(
"ops".to_owned(),
"box-1".to_owned(),
"foot".to_owned(),
None,
);
assert_eq!(
gesture,
json!({"op": "enroll", "workspace": "ops", "name": "box-1", "grade": "foot"})
);
assert_eq!(gesture.get(ADDRESS), None);
}
#[test]
fn a_stated_route_rides_the_gesture_under_the_wire_s_own_name() {
let gesture = enroll(
"ops".to_owned(),
"box-1".to_owned(),
"foot".to_owned(),
Some("host.containers.internal:7773".to_owned()),
);
assert_eq!(
gesture,
json!({
"op": "enroll",
"workspace": "ops",
"name": "box-1",
"grade": "foot",
"address": "host.containers.internal:7773",
})
);
}
#[test]
fn the_optional_field_is_not_a_fourth_parameter() {
assert_eq!(ENROLL.params, &["workspace", "name", "grade"]);
assert_eq!(ENROLL.usage(), "lernie enroll <workspace> <name> <grade>");
}