forked from 1b-agent/opencadstudio-upstream
fix(doc-api): preserve XDATA and XRecord integrity
This commit is contained in:
1 parent
acba9f87bd
commit
4de2792798
9 files changed
+367
-108
No files matched your search
@@ -985,6 +985,39 @@ fn set_xdata_many_with_unknown_id_fails_atomically() {
|
||||
assert!(doc.entities().get(line.id()).unwrap().xdata("APP1").unwrap().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xdata_rejects_a_mismatched_record_name() {
|
||||
let (api, _tp) = api();
|
||||
let doc = api.document(api.active_tab());
|
||||
let line = doc.curves().create_line([0.0; 3], [1.0; 3]).unwrap();
|
||||
let entity = doc.entities().get(line.id()).unwrap();
|
||||
let result = entity.set_xdata(
|
||||
"EXPECTED",
|
||||
Some(XDataRecord {
|
||||
application_name: "OTHER".into(),
|
||||
values: vec![],
|
||||
}),
|
||||
);
|
||||
assert!(matches!(result, Err(ApiError::Validation { .. })));
|
||||
assert!(entity.xdata("EXPECTED").unwrap().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_xrecord_returns_the_typed_handle() {
|
||||
let (api, _tp) = api();
|
||||
let doc = api.document(api.active_tab());
|
||||
let spec = ocs_doc_api::XRecordSpec {
|
||||
name: "PLUGIN_DATA".into(),
|
||||
cloning_flags: ocs_doc_api::XRecordCloningFlags::NotApplicable,
|
||||
entries: vec![ocs_doc_api::XRecordEntry {
|
||||
code: 1,
|
||||
value: ocs_doc_api::XRecordValue::String("value".into()),
|
||||
}],
|
||||
};
|
||||
let record = doc.entities().create_xrecord(&spec).unwrap();
|
||||
assert_eq!(record.payload().unwrap(), spec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_many_applies_per_curve_layer() {
|
||||
let (api, _tp) = api();
|
||||
|
||||
Reference in new issue
Block a user