use super::Instance;
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct Application {
pub name: String,
pub instance: Vec<Instance>,
}
#[cfg(test)]
mod tests {
use super::super::instance::tests::{build_test_instance, build_test_instance_json};
use super::*;
use serde_json;
#[test]
fn test_instance_serialization() {
let json = build_register_json();
let instance = build_test_instance();
let name = "test_name";
let app = Application {
name: name.to_owned(),
instance: vec![instance],
};
let result = serde_json::to_string(&app).unwrap();
assert_eq!(json, result);
}
#[test]
fn test_instance_deserialization() {
let json = build_register_json();
let instance = build_test_instance();
let name = "test_name";
let app = Application {
name: name.to_owned(),
instance: vec![instance],
};
let result = serde_json::from_str(&json).unwrap();
assert_eq!(app, result);
}
fn build_register_json() -> String {
format!(
"{{\"name\":\"test_name\",\"instance\":[{}]}}",
build_test_instance_json()
)
}
}