mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-01-21 18:03:59 +03:00
add test for VerifyFn
This commit is contained in:
parent
715f22fb4a
commit
a23dd9bb42
@ -644,3 +644,20 @@ fn test_query_boolean() {
|
||||
assert!(res.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_verify_function() {
|
||||
|
||||
let schema = ObjectSchema::new("Parameters.")
|
||||
.required(
|
||||
"p1", StringSchema::new("P1")
|
||||
.format(ApiStringFormat::VerifyFn(|value| {
|
||||
if value == "test" { return Ok(()) };
|
||||
bail!("format error");
|
||||
}).into())
|
||||
);
|
||||
|
||||
let res = parse_query_string("p1=tes", &schema, true);
|
||||
assert!(res.is_err());
|
||||
let res = parse_query_string("p1=test", &schema, true);
|
||||
assert!(res.is_ok());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user