Line data Source code
1 : use super::*;
2 :
3 : #[test]
4 1 : fn test_node_metadata_v1_backward_compatibilty() {
5 1 : let v1 = serde_json::to_vec(&serde_json::json!({
6 1 : "host": "localhost",
7 1 : "port": 23,
8 1 : "http_host": "localhost",
9 1 : "http_port": 42,
10 1 : }));
11 :
12 1 : assert_eq!(
13 1 : serde_json::from_slice::<NodeMetadata>(&v1.unwrap()).unwrap(),
14 1 : NodeMetadata {
15 1 : postgres_host: "localhost".to_string(),
16 1 : postgres_port: 23,
17 1 : grpc_host: None,
18 1 : grpc_port: None,
19 1 : http_host: "localhost".to_string(),
20 1 : http_port: 42,
21 1 : https_port: None,
22 1 : other: HashMap::new(),
23 1 : }
24 : )
25 1 : }
26 :
27 : #[test]
28 1 : fn test_node_metadata_v2_backward_compatibilty() {
29 1 : let v2 = serde_json::to_vec(&serde_json::json!({
30 1 : "host": "localhost",
31 1 : "port": 23,
32 1 : "http_host": "localhost",
33 1 : "http_port": 42,
34 1 : "https_port": 123,
35 1 : }));
36 :
37 1 : assert_eq!(
38 1 : serde_json::from_slice::<NodeMetadata>(&v2.unwrap()).unwrap(),
39 1 : NodeMetadata {
40 1 : postgres_host: "localhost".to_string(),
41 1 : postgres_port: 23,
42 1 : grpc_host: None,
43 1 : grpc_port: None,
44 1 : http_host: "localhost".to_string(),
45 1 : http_port: 42,
46 1 : https_port: Some(123),
47 1 : other: HashMap::new(),
48 1 : }
49 : )
50 1 : }
51 :
52 : #[test]
53 1 : fn test_node_metadata_v3_backward_compatibilty() {
54 1 : let v3 = serde_json::to_vec(&serde_json::json!({
55 1 : "host": "localhost",
56 1 : "port": 23,
57 1 : "grpc_host": "localhost",
58 1 : "grpc_port": 51,
59 1 : "http_host": "localhost",
60 1 : "http_port": 42,
61 1 : "https_port": 123,
62 1 : }));
63 :
64 1 : assert_eq!(
65 1 : serde_json::from_slice::<NodeMetadata>(&v3.unwrap()).unwrap(),
66 1 : NodeMetadata {
67 1 : postgres_host: "localhost".to_string(),
68 1 : postgres_port: 23,
69 1 : grpc_host: Some("localhost".to_string()),
70 1 : grpc_port: Some(51),
71 1 : http_host: "localhost".to_string(),
72 1 : http_port: 42,
73 1 : https_port: Some(123),
74 1 : other: HashMap::new(),
75 1 : }
76 : )
77 1 : }
|