move test code

This commit is contained in:
Dietmar Maurer 2018-11-03 09:08:01 +01:00
parent 18671ca530
commit 0e6967d648
2 changed files with 45 additions and 39 deletions

View File

@ -141,3 +141,48 @@ macro_rules! propertymap {
} }
} }
} }
#[test]
fn test_shema1() {
static PARAMETERS1: PropertyMap = propertymap!{
force => &Boolean!{
description => "Test for boolean options."
},
text1 => &ApiString!{
description => "A simple text string.",
min_length => Some(10),
max_length => Some(30)
},
count => &Integer!{
description => "A counter for everything.",
minimum => Some(0),
maximum => Some(10)
},
myarray1 => &Array!{
description => "Test Array of simple integers.",
items => &PVE_VMID
},
myarray2 => &Jss::Array(JssArray {
description: "Test Array of simple integers.",
optional: Some(false),
items: &Object!{description => "Empty Object."},
}),
myobject => &Object!{
description => "TEST Object.",
properties => &propertymap!{
vmid => &PVE_VMID,
loop => &Integer!{
description => "Totally useless thing.",
optional => Some(false)
}
}
},
emptyobject => &Object!{description => "Empty Object."}
};
for (k, v) in PARAMETERS1.entries {
println!("Parameter: {} Value: {:?}", k, v);
}
}

View File

@ -18,41 +18,6 @@ use hyper::{Method, Body, Request, Response, Server, StatusCode};
use hyper::rt::Future; use hyper::rt::Future;
use hyper::service::service_fn_ok; use hyper::service::service_fn_ok;
static PARAMETERS1: PropertyMap = propertymap!{
force => &Boolean!{
description => "Test for boolean options."
},
text1 => &ApiString!{
description => "A simple text string.",
min_length => Some(10),
max_length => Some(30)
},
count => &Integer!{
description => "A counter for everything.",
minimum => Some(0),
maximum => Some(10)
},
myarray1 => &Array!{
description => "Test Array of simple integers.",
items => &PVE_VMID
},
myarray2 => &Jss::Array(JssArray {
description: "Test Array of simple integers.",
optional: Some(false),
items: &Object!{description => "Empty Object."},
}),
myobject => &Object!{
description => "TEST Object.",
properties => &propertymap!{
vmid => &PVE_VMID,
loop => &Integer!{
description => "Totally useless thing.",
optional => Some(false)
}
}
},
emptyobject => &Object!{description => "Empty Object."}
};
@ -198,10 +163,6 @@ fn handle_request(req: Request<Body>) -> Response<Body> {
fn main() { fn main() {
println!("Fast Static Type Definitions 1"); println!("Fast Static Type Definitions 1");
for (k, v) in PARAMETERS1.entries {
println!("Parameter: {} Value: {:?}", k, v);
}
let addr = ([127, 0, 0, 1], 8007).into(); let addr = ([127, 0, 0, 1], 8007).into();
let new_svc = || { let new_svc = || {