From 0e6967d6487b95d12ab945e06ab57ef5deff7197 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sat, 3 Nov 2018 09:08:01 +0100 Subject: [PATCH] move test code --- src/json_schema.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 39 --------------------------------------- 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/json_schema.rs b/src/json_schema.rs index c9722fb4..4e8ef827 100644 --- a/src/json_schema.rs +++ b/src/json_schema.rs @@ -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); + } + + +} diff --git a/src/main.rs b/src/main.rs index 735b9448..8949003e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,41 +18,6 @@ use hyper::{Method, Body, Request, Response, Server, StatusCode}; use hyper::rt::Future; 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) -> Response { fn main() { 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 new_svc = || {