fix(protocol): reject unknown root named types
This commit is contained in:
@@ -233,6 +233,44 @@ fn named_references_must_exist_and_must_not_cycle() {
|
||||
]
|
||||
);
|
||||
|
||||
let valid = descriptor("catalog");
|
||||
let error = valid
|
||||
.validate_value(&TypeExpr::Named("Elsewhere".into()), &Value::Record(vec![]))
|
||||
.unwrap_err();
|
||||
assert_eq!(
|
||||
error.kind,
|
||||
ValidationErrorKind::UnknownType {
|
||||
name: "Elsewhere".into()
|
||||
}
|
||||
);
|
||||
assert_eq!(error.path, vec![PathSegment::Interface("catalog".into())]);
|
||||
|
||||
let error = valid
|
||||
.validate_value(
|
||||
&TypeExpr::Entry {
|
||||
key: Box::new(TypeExpr::String),
|
||||
value: Box::new(TypeExpr::List(Box::new(TypeExpr::Named("Nested".into())))),
|
||||
},
|
||||
&Value::Entry {
|
||||
key: Box::new(Value::String("key".into())),
|
||||
value: Box::new(Value::List(vec![])),
|
||||
},
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(
|
||||
error.kind,
|
||||
ValidationErrorKind::UnknownType {
|
||||
name: "Nested".into()
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
error.path,
|
||||
vec![
|
||||
PathSegment::Interface("catalog".into()),
|
||||
PathSegment::EntryValue,
|
||||
]
|
||||
);
|
||||
|
||||
let cyclic = InterfaceDescriptor {
|
||||
name: "cyclic".into(),
|
||||
documentation: None,
|
||||
|
||||
Reference in New Issue
Block a user