use std::collections::HashMap;
use epics_base_rs::server::ioc_builder::IocBuilder;
async fn load(db: &str) -> Result<(), String> {
let builder = IocBuilder::new()
.db_string(db, &HashMap::new())
.expect("parse is fine — the refusal happens at field application");
match builder.build().await {
Ok(_) => Ok(()),
Err(e) => Err(e.to_string()),
}
}
#[epics_macros_rs::epics_test]
async fn lso_val_in_db_is_refused_with_the_real_reason() {
let msg = load(r#"record(lso, "L") { field(VAL, "hello") }"#)
.await
.expect_err("C refuses lso VAL from a .db (measured on softIoc)");
assert!(
msg.contains("before iocInit"),
"diagnostic must name the real constraint, got: {msg}"
);
assert!(
!msg.contains("cannot parse"),
"must not blame the value's syntax, got: {msg}"
);
}
#[epics_macros_rs::epics_test]
async fn printf_val_in_db_is_refused_and_other_lso_fields_still_load() {
let msg = load(r#"record(printf, "P") { field(VAL, "x") }"#)
.await
.expect_err("printf VAL is the same DBF_NOACCESS refusal family");
assert!(msg.contains("before iocInit"), "got: {msg}");
load(r#"record(lso, "L2") { field(SIZV, "80") }"#)
.await
.expect("non-long-string lso fields must still load");
}