File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,27 @@ pub fn load_config(path: &str) -> GatewayConfig {
21
21
file. read_to_string ( & mut contents) . unwrap ( ) ;
22
22
toml:: from_str ( & contents) . unwrap ( )
23
23
}
24
+
25
+ #[ cfg( test) ]
26
+ mod tests {
27
+ use super :: * ;
28
+
29
+ #[ test]
30
+ fn parses_config ( ) -> Result < ( ) , std:: io:: Error > {
31
+ let config = load_config ( "./tests/test_config.toml" ) ;
32
+ let test_service = config
33
+ . services
34
+ . get ( "test-service" )
35
+ . expect ( "test service not found" ) ;
36
+
37
+ assert_eq ! ( config. auth_url, "https://example.com" ) ;
38
+ assert_eq ! ( test_service. path, "/testservice" ) ;
39
+ assert_eq ! (
40
+ test_service. target_host,
41
+ "https://my-service.default.svc.cluster.local"
42
+ ) ;
43
+ assert_eq ! ( test_service. target_port, 8080 ) ;
44
+
45
+ Ok ( ( ) )
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ auth_url =" https://example.com"
2
+
3
+ [services .test-service ]
4
+ path =" /testservice"
5
+ target_host =" https://my-service.default.svc.cluster.local"
6
+ target_port =8080
You can’t perform that action at this time.
0 commit comments