@@ -74,6 +74,43 @@ public void testKubectlLabelNamespacedResourceShouldWork() throws KubectlExcepti
74
74
assertNotNull (labelledPod );
75
75
}
76
76
77
+ @ Test
78
+ public void testKubectlDeleteLabelNamespacedResourceShouldWork () throws KubectlException {
79
+ wireMockRule .stubFor (
80
+ get (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" ))
81
+ .willReturn (
82
+ aResponse ()
83
+ .withStatus (200 )
84
+ .withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
85
+ wireMockRule .stubFor (
86
+ put (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" ))
87
+ .willReturn (
88
+ aResponse ()
89
+ .withStatus (200 )
90
+ .withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
91
+
92
+ Kubectl .label (V1Pod .class )
93
+ .apiClient (apiClient )
94
+ .skipDiscovery ()
95
+ .namespace ("default" )
96
+ .name ("foo" )
97
+ .addLabel ("k1" , "v1" )
98
+ .execute ();
99
+
100
+ V1Pod unlabelledPod =
101
+ Kubectl .label (V1Pod .class )
102
+ .apiClient (apiClient )
103
+ .skipDiscovery ()
104
+ .namespace ("default" )
105
+ .name ("foo" )
106
+ .deleteLabel ("k1" )
107
+ .execute ();
108
+
109
+ wireMockRule .verify (2 , getRequestedFor (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" )));
110
+ wireMockRule .verify (2 , putRequestedFor (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" )));
111
+ assertNotNull (unlabelledPod );
112
+ }
113
+
77
114
@ Test
78
115
public void testKubectlLabelNamespacedResourceReceiveForbiddenShouldThrowException ()
79
116
throws KubectlException {
@@ -123,6 +160,35 @@ public void testKubectlLabelClusterResourceShouldWork() throws KubectlException
123
160
assertNotNull (labelledNode );
124
161
}
125
162
163
+ @ Test
164
+ public void testKubectlDeleteLabelClusterResourceShouldWork () throws KubectlException {
165
+ wireMockRule .stubFor (
166
+ get (urlPathEqualTo ("/api/v1/nodes/foo" ))
167
+ .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
168
+ wireMockRule .stubFor (
169
+ put (urlPathEqualTo ("/api/v1/nodes/foo" ))
170
+ .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
171
+
172
+ Kubectl .label (V1Node .class )
173
+ .apiClient (apiClient )
174
+ .skipDiscovery ()
175
+ .name ("foo" )
176
+ .addLabel ("k1" , "v1" )
177
+ .execute ();
178
+
179
+ V1Node unlabelledNode =
180
+ Kubectl .label (V1Node .class )
181
+ .apiClient (apiClient )
182
+ .skipDiscovery ()
183
+ .name ("foo" )
184
+ .deleteLabel ("k1" )
185
+ .execute ();
186
+ wireMockRule .verify (2 , getRequestedFor (urlPathEqualTo ("/api/v1/nodes/foo" )));
187
+ wireMockRule .verify (2 , putRequestedFor (urlPathEqualTo ("/api/v1/nodes/foo" )));
188
+ assertNotNull (unlabelledNode );
189
+ }
190
+
191
+
126
192
@ Test
127
193
public void testKubectlLabelClusterResourceReceiveForbiddenShouldThrowException ()
128
194
throws KubectlException {
0 commit comments