@@ -1082,6 +1082,53 @@ var _ = Describe("EndpointPool", func() {
10821082 })
10831083 })
10841084
1085+ Context ("when endpoints have route policy fields" , func () {
1086+ It ("marshals json with route_policy_scope and route_policies" , func () {
1087+ e := route .NewEndpoint (& route.EndpointOpts {
1088+ Host : "1.2.3.4" ,
1089+ Port : 5678 ,
1090+ Protocol : "http2" ,
1091+ StaleThresholdInSeconds : - 1 ,
1092+ RoutePolicyScope : route .RoutePolicyScopeOrg ,
1093+ RoutePolicies : []string {"cf:org:org-guid-1" , "cf:app:app-guid-1" },
1094+ })
1095+ pool .Put (e )
1096+
1097+ json , err := pool .MarshalJSON ()
1098+ Expect (err ).ToNot (HaveOccurred ())
1099+ Expect (string (json )).To (Equal (`[{"address":"1.2.3.4:5678","availability_zone":"","protocol":"http2","tls":false,"ttl":-1,"tags":null,"route_policy_scope":"org","route_policies":["cf:org:org-guid-1","cf:app:app-guid-1"]}]` ))
1100+ })
1101+
1102+ It ("marshals json with route_policy_scope only" , func () {
1103+ e := route .NewEndpoint (& route.EndpointOpts {
1104+ Host : "1.2.3.4" ,
1105+ Port : 5678 ,
1106+ Protocol : "http2" ,
1107+ StaleThresholdInSeconds : - 1 ,
1108+ RoutePolicyScope : route .RoutePolicyScopeSpace ,
1109+ })
1110+ pool .Put (e )
1111+
1112+ json , err := pool .MarshalJSON ()
1113+ Expect (err ).ToNot (HaveOccurred ())
1114+ Expect (string (json )).To (Equal (`[{"address":"1.2.3.4:5678","availability_zone":"","protocol":"http2","tls":false,"ttl":-1,"tags":null,"route_policy_scope":"space"}]` ))
1115+ })
1116+
1117+ It ("omits route policy fields when empty" , func () {
1118+ e := route .NewEndpoint (& route.EndpointOpts {
1119+ Host : "1.2.3.4" ,
1120+ Port : 5678 ,
1121+ Protocol : "http2" ,
1122+ StaleThresholdInSeconds : - 1 ,
1123+ })
1124+ pool .Put (e )
1125+
1126+ json , err := pool .MarshalJSON ()
1127+ Expect (err ).ToNot (HaveOccurred ())
1128+ Expect (string (json )).To (Equal (`[{"address":"1.2.3.4:5678","availability_zone":"","protocol":"http2","tls":false,"ttl":-1,"tags":null}]` ))
1129+ })
1130+ })
1131+
10851132 Describe ("ProcessId" , func () {
10861133 Context ("when there are no tags" , func () {
10871134 It ("returns an empty string" , func () {
0 commit comments