@@ -176,6 +176,90 @@ func TestGatewaysPrinter_PrintTable(t *testing.T) {
176
176
},
177
177
},
178
178
},
179
+ & gatewayv1.HTTPRoute {
180
+ TypeMeta : metav1.TypeMeta {
181
+ Kind : "HTTPRoute" ,
182
+ },
183
+ ObjectMeta : metav1.ObjectMeta {
184
+ Name : "foo-httproute" ,
185
+ },
186
+ Spec : gatewayv1.HTTPRouteSpec {
187
+ CommonRouteSpec : gatewayv1.CommonRouteSpec {
188
+ ParentRefs : []gatewayv1.ParentReference {{
189
+ Kind : common .PtrTo (gatewayv1 .Kind ("Gateway" )),
190
+ Group : common .PtrTo (gatewayv1 .Group ("gateway.networking.k8s.io" )),
191
+ Name : "abc-gateway-12345" ,
192
+ }},
193
+ },
194
+ },
195
+ },
196
+
197
+ & apiextensionsv1.CustomResourceDefinition {
198
+ ObjectMeta : metav1.ObjectMeta {
199
+ Name : "healthcheckpolicies.foo.com" ,
200
+ Labels : map [string ]string {
201
+ gatewayv1alpha2 .PolicyLabelKey : "inherited" ,
202
+ },
203
+ },
204
+ Spec : apiextensionsv1.CustomResourceDefinitionSpec {
205
+ Scope : apiextensionsv1 .ClusterScoped ,
206
+ Group : "foo.com" ,
207
+ Versions : []apiextensionsv1.CustomResourceDefinitionVersion {{Name : "v1" }},
208
+ Names : apiextensionsv1.CustomResourceDefinitionNames {
209
+ Plural : "healthcheckpolicies" ,
210
+ Kind : "HealthCheckPolicy" ,
211
+ },
212
+ },
213
+ },
214
+ & unstructured.Unstructured {
215
+ Object : map [string ]interface {}{
216
+ "apiVersion" : "foo.com/v1" ,
217
+ "kind" : "HealthCheckPolicy" ,
218
+ "metadata" : map [string ]interface {}{
219
+ "name" : "health-check-gatewayclass" ,
220
+ },
221
+ "spec" : map [string ]interface {}{
222
+ "override" : map [string ]interface {}{
223
+ "key1" : "value-parent-1" ,
224
+ "key3" : "value-parent-3" ,
225
+ "key5" : "value-parent-5" ,
226
+ },
227
+ "default" : map [string ]interface {}{
228
+ "key2" : "value-parent-2" ,
229
+ "key4" : "value-parent-4" ,
230
+ },
231
+ "targetRef" : map [string ]interface {}{
232
+ "group" : "gateway.networking.k8s.io" ,
233
+ "kind" : "GatewayClass" ,
234
+ "name" : "regional-internal-class" ,
235
+ },
236
+ },
237
+ },
238
+ },
239
+ & unstructured.Unstructured {
240
+ Object : map [string ]interface {}{
241
+ "apiVersion" : "foo.com/v1" ,
242
+ "kind" : "HealthCheckPolicy" ,
243
+ "metadata" : map [string ]interface {}{
244
+ "name" : "health-check-gateway" ,
245
+ },
246
+ "spec" : map [string ]interface {}{
247
+ "override" : map [string ]interface {}{
248
+ "key1" : "value-child-1" ,
249
+ },
250
+ "default" : map [string ]interface {}{
251
+ "key2" : "value-child-2" ,
252
+ "key5" : "value-child-5" ,
253
+ },
254
+ "targetRef" : map [string ]interface {}{
255
+ "group" : "gateway.networking.k8s.io" ,
256
+ "kind" : "Gateway" ,
257
+ "name" : "random-gateway" ,
258
+ "namespace" : "default" ,
259
+ },
260
+ },
261
+ },
262
+ },
179
263
}
180
264
181
265
k8sClients := common .MustClientsForTest (t , objects ... )
@@ -194,7 +278,7 @@ func TestGatewaysPrinter_PrintTable(t *testing.T) {
194
278
Writer : buff ,
195
279
Clock : fakeClock ,
196
280
}
197
- gp .PrintTable (resourceModel )
281
+ gp .PrintTable (resourceModel , false )
198
282
199
283
got := buff .String ()
200
284
want := `
@@ -207,6 +291,24 @@ default random-gateway regional-internal-class 10.11.12.13
207
291
if diff := cmp .Diff (common .YamlString (want ), common .YamlString (got ), common .YamlStringTransformer ); diff != "" {
208
292
t .Errorf ("Unexpected diff\n got=\n %v\n want=\n %v\n diff (-want +got)=\n %v" , got , want , diff )
209
293
}
294
+
295
+ buff .Reset ()
296
+ nsp2 := & GatewaysPrinter {
297
+ Writer : buff ,
298
+ Clock : fakeClock ,
299
+ }
300
+ nsp2 .PrintTable (resourceModel , true )
301
+
302
+ got2 := buff .String ()
303
+ want2 := `
304
+ NAMESPACE NAME CLASS ADDRESSES PORTS PROGRAMMED AGE POLICIES HTTPROUTES
305
+ default abc-gateway-12345 internal-class 192.168.100.5 443,8080 False 20d 0 1
306
+ default demo-gateway-2 external-class 10.0.0.1,10.0.0.2 + 1 more 80 True 5d 0 0
307
+ default random-gateway regional-internal-class 10.11.12.13 8443 Unknown 3s 1 0
308
+ `
309
+ if diff := cmp .Diff (common .YamlString (want2 ), common .YamlString (got2 ), common .YamlStringTransformer ); diff != "" {
310
+ t .Errorf ("Unexpected diff\n got=\n %v\n want=\n %v\n diff (-want +got)=\n %v" , got2 , want2 , diff )
311
+ }
210
312
}
211
313
212
314
func TestGatewaysPrinter_PrintDescribeView (t * testing.T ) {
0 commit comments