@@ -79,6 +79,43 @@ public void testKubectlLabelNamespacedResourceShouldWork() throws KubectlExcepti
7979 assertNotNull (labelledPod );
8080 }
8181
82+ @ Test
83+ public void testKubectlDeleteLabelNamespacedResourceShouldWork () throws KubectlException {
84+ wireMockRule .stubFor (
85+ get (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" ))
86+ .willReturn (
87+ aResponse ()
88+ .withStatus (200 )
89+ .withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
90+ wireMockRule .stubFor (
91+ put (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" ))
92+ .willReturn (
93+ aResponse ()
94+ .withStatus (200 )
95+ .withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
96+
97+ Kubectl .label (V1Pod .class )
98+ .apiClient (apiClient )
99+ .skipDiscovery ()
100+ .namespace ("default" )
101+ .name ("foo" )
102+ .addLabel ("k1" , "v1" )
103+ .execute ();
104+
105+ V1Pod unlabelledPod =
106+ Kubectl .label (V1Pod .class )
107+ .apiClient (apiClient )
108+ .skipDiscovery ()
109+ .namespace ("default" )
110+ .name ("foo" )
111+ .deleteLabel ("k1" )
112+ .execute ();
113+
114+ wireMockRule .verify (2 , getRequestedFor (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" )));
115+ wireMockRule .verify (2 , putRequestedFor (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" )));
116+ assertNotNull (unlabelledPod );
117+ }
118+
82119 @ Test
83120 public void testKubectlLabelNamespacedResourceReceiveForbiddenShouldThrowException ()
84121 throws KubectlException {
@@ -134,6 +171,35 @@ public void testKubectlLabelClusterResourceShouldWork() throws KubectlException
134171 assertNotNull (labelledNode );
135172 }
136173
174+ @ Test
175+ public void testKubectlDeleteLabelClusterResourceShouldWork () throws KubectlException {
176+ wireMockRule .stubFor (
177+ get (urlPathEqualTo ("/api/v1/nodes/foo" ))
178+ .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
179+ wireMockRule .stubFor (
180+ put (urlPathEqualTo ("/api/v1/nodes/foo" ))
181+ .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
182+
183+ Kubectl .label (V1Node .class )
184+ .apiClient (apiClient )
185+ .skipDiscovery ()
186+ .name ("foo" )
187+ .addLabel ("k1" , "v1" )
188+ .execute ();
189+
190+ V1Node unlabelledNode =
191+ Kubectl .label (V1Node .class )
192+ .apiClient (apiClient )
193+ .skipDiscovery ()
194+ .name ("foo" )
195+ .deleteLabel ("k1" )
196+ .execute ();
197+ wireMockRule .verify (2 , getRequestedFor (urlPathEqualTo ("/api/v1/nodes/foo" )));
198+ wireMockRule .verify (2 , putRequestedFor (urlPathEqualTo ("/api/v1/nodes/foo" )));
199+ assertNotNull (unlabelledNode );
200+ }
201+
202+
137203 @ Test
138204 public void testKubectlLabelClusterResourceReceiveForbiddenShouldThrowException ()
139205 throws KubectlException {
0 commit comments