rust_eureka/response/
application.rs1use super::Instance;
2
3#[derive(Debug, PartialEq, Serialize, Deserialize)]
4pub struct Application {
5 pub name: String,
6 pub instance: Instance
7}
8
9
10#[cfg(test)]
11mod tests {
12 use serde_json;
13 use super::*;
14 use super::super::instance::tests::{build_test_instance, build_test_instance_json};
15
16 #[test]
17 fn test_instance_serialization() {
18 let json = build_register_json();
19 let instance = build_test_instance();
20 let name = "test_name";
21 let app = Application{
22 name: name.to_owned(),
23 instance: instance
24 };
25 let result = serde_json::to_string(&app).unwrap();
26
27 assert_eq!(json, result);
33 }
34
35 #[test]
36 fn test_instance_deserialization() {
37 let json = build_register_json();
38 let instance = build_test_instance();
39 let name = "test_name";
40 let app = Application{
41 name: name.to_owned(),
42 instance: instance
43 };
44 let result = serde_json::from_str(&json).unwrap();
45 assert_eq!(app, result);
46 }
47
48 fn build_register_json() -> String {
49 format!("{{\"name\":\"test_name\",\"instance\":{}}}", build_test_instance_json())
50 }
51}
52