1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#[macro_use] extern crate serde; extern crate serde_derive; extern crate serde_json; pub mod runtime; mod serdes; #[cfg(test)] mod tests { use crate::runtime::{Spec, State}; use std::collections::HashMap; use std::io::{Write, BufWriter}; #[test] fn test_load() { match Spec::load("config.json") { Ok(_) => {}, Err(e) => panic!("{}", e), } } #[test] fn test_save() { let spec = match Spec::load("config.json") { Ok(s) => s, Err(e) => panic!("{}", e), }; match Spec::save(&spec, "config.json") { Ok(_) => {}, Err(e) => panic!("{}", e), } } #[test] fn test_writer() { let buf = Vec::new(); let mut writer = BufWriter::new(buf); let state = State { version: "1.0.1-dev".to_string(), id: 1000.to_string(), status: "created".to_string(), pid: Some(1), bundle: "/test".to_string(), annotations: Some(HashMap::new()), }; match State::to_writer(&state, writer.by_ref()) { Ok(_) => {}, Err(e) => panic!("{}", e), } } #[test] fn test_string() { let state = State { version: "1.0.1-dev".to_string(), id: 1000.to_string(), status: "created".to_string(), pid: Some(1), bundle: "/test".to_string(), annotations: Some(HashMap::new()), }; match State::to_string(&state) { Ok(_) => {}, Err(e) => panic!("{}", e), } } }