@@ -40,26 +40,79 @@ func TestGatewaysPrinter_Print(t *testing.T) {
40
40
objects := []runtime.Object {
41
41
& gatewayv1.GatewayClass {
42
42
ObjectMeta : metav1.ObjectMeta {
43
- Name : "foo-gatewayclass" ,
43
+ Name : "internal-class" ,
44
+ },
45
+ Spec : gatewayv1.GatewayClassSpec {
46
+ ControllerName : "example.net/gateway-controller" ,
47
+ Description : common .PtrTo ("random" ),
48
+ },
49
+ },
50
+ & gatewayv1.GatewayClass {
51
+ ObjectMeta : metav1.ObjectMeta {
52
+ Name : "external-class" ,
53
+ },
54
+ Spec : gatewayv1.GatewayClassSpec {
55
+ ControllerName : "example.net/gateway-controller" ,
56
+ Description : common .PtrTo ("random" ),
57
+ },
58
+ },
59
+ & gatewayv1.GatewayClass {
60
+ ObjectMeta : metav1.ObjectMeta {
61
+ Name : "regional-internal-class" ,
44
62
},
45
63
Spec : gatewayv1.GatewayClassSpec {
46
64
ControllerName : "example.net/gateway-controller" ,
47
65
Description : common .PtrTo ("random" ),
48
66
},
49
67
},
50
-
51
68
& gatewayv1.Gateway {
52
69
ObjectMeta : metav1.ObjectMeta {
53
- Name : "foo -gateway" ,
70
+ Name : "abc -gateway-12345 " ,
54
71
CreationTimestamp : metav1.Time {
55
- Time : fakeClock .Now ().Add (- time .Second ),
72
+ Time : fakeClock .Now ().Add (- 20 * 24 * time .Hour ),
56
73
},
57
74
},
58
75
Spec : gatewayv1.GatewaySpec {
59
- GatewayClassName : "foo-gatewayclass" ,
76
+ GatewayClassName : "internal-class" ,
77
+ Listeners : []gatewayv1.Listener {
78
+ {
79
+ Name : gatewayv1 .SectionName ("https-443" ),
80
+ Protocol : gatewayv1 .HTTPSProtocolType ,
81
+ Port : gatewayv1 .PortNumber (443 ),
82
+ },
83
+ {
84
+ Name : gatewayv1 .SectionName ("http-8080" ),
85
+ Protocol : gatewayv1 .HTTPProtocolType ,
86
+ Port : gatewayv1 .PortNumber (8080 ),
87
+ },
88
+ },
89
+ },
90
+ Status : gatewayv1.GatewayStatus {
91
+ Addresses : []gatewayv1.GatewayStatusAddress {
92
+ {
93
+ Value : "192.168.100.5" ,
94
+ },
95
+ },
96
+ Conditions : []metav1.Condition {
97
+ {
98
+ Type : "Programmed" ,
99
+ Status : "False" ,
100
+ },
101
+ },
102
+ },
103
+ },
104
+ & gatewayv1.Gateway {
105
+ ObjectMeta : metav1.ObjectMeta {
106
+ Name : "demo-gateway-2" ,
107
+ CreationTimestamp : metav1.Time {
108
+ Time : fakeClock .Now ().Add (- 5 * 24 * time .Hour ),
109
+ },
110
+ },
111
+ Spec : gatewayv1.GatewaySpec {
112
+ GatewayClassName : "external-class" ,
60
113
Listeners : []gatewayv1.Listener {
61
114
{
62
- Name : gatewayv1 .SectionName ("http-1 " ),
115
+ Name : gatewayv1 .SectionName ("http-80 " ),
63
116
Protocol : gatewayv1 .HTTPProtocolType ,
64
117
Port : gatewayv1 .PortNumber (80 ),
65
118
},
@@ -70,11 +123,48 @@ func TestGatewaysPrinter_Print(t *testing.T) {
70
123
{
71
124
Value : "10.0.0.1" ,
72
125
},
126
+ {
127
+ Value : "10.0.0.2" ,
128
+ },
129
+ {
130
+ Value : "10.0.0.3" ,
131
+ },
132
+ },
133
+ Conditions : []metav1.Condition {
134
+ {
135
+ Type : "Programmed" ,
136
+ Status : "True" ,
137
+ },
138
+ },
139
+ },
140
+ },
141
+ & gatewayv1.Gateway {
142
+ ObjectMeta : metav1.ObjectMeta {
143
+ Name : "random-gateway" ,
144
+ CreationTimestamp : metav1.Time {
145
+ Time : fakeClock .Now ().Add (- 3 * time .Second ),
146
+ },
147
+ },
148
+ Spec : gatewayv1.GatewaySpec {
149
+ GatewayClassName : "regional-internal-class" ,
150
+ Listeners : []gatewayv1.Listener {
151
+ {
152
+ Name : gatewayv1 .SectionName ("http-8443" ),
153
+ Protocol : gatewayv1 .HTTPProtocolType ,
154
+ Port : gatewayv1 .PortNumber (8443 ),
155
+ },
156
+ },
157
+ },
158
+ Status : gatewayv1.GatewayStatus {
159
+ Addresses : []gatewayv1.GatewayStatusAddress {
160
+ {
161
+ Value : "10.11.12.13" ,
162
+ },
73
163
},
74
164
Conditions : []metav1.Condition {
75
165
{
76
166
Type : "Programmed" ,
77
- Status : metav1 . ConditionTrue ,
167
+ Status : "Unknown" ,
78
168
},
79
169
},
80
170
},
@@ -99,8 +189,10 @@ func TestGatewaysPrinter_Print(t *testing.T) {
99
189
100
190
got := params .Out .(* bytes.Buffer ).String ()
101
191
want := `
102
- NAME CLASS ADDRESSES PORTS PROGRAMMED AGE
103
- foo-gateway foo-gatewayclass 10.0.0.1 80 True 1s
192
+ NAME CLASS ADDRESSES PORTS PROGRAMMED AGE
193
+ abc-gateway-12345 internal-class 192.168.100.5 443,8080 False 20d
194
+ demo-gateway-2 external-class 10.0.0.1,10.0.0.2 + 1 more 80 True 5d
195
+ random-gateway regional-internal-class 10.11.12.13 8443 Unknown 3s
104
196
`
105
197
106
198
if diff := cmp .Diff (common .YamlString (want ), common .YamlString (got ), common .YamlStringTransformer ); diff != "" {
0 commit comments