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