@@ -79,6 +79,37 @@ 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+ .withRequestBody (
93+ matchingJsonPath ("$.metadata.labels" , equalToJson ("{ \" k1\" : \" null\" }" )))
94+ .willReturn (
95+ aResponse ()
96+ .withStatus (200 )
97+ .withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
98+
99+ V1Pod unlabelledPod =
100+ Kubectl .label (V1Pod .class )
101+ .apiClient (apiClient )
102+ .skipDiscovery ()
103+ .namespace ("default" )
104+ .name ("foo" )
105+ .deleteLabel ("k1" )
106+ .execute ();
107+
108+ wireMockRule .verify (1 , getRequestedFor (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" )));
109+ wireMockRule .verify (1 , putRequestedFor (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" )));
110+ assertNotNull (unlabelledPod );
111+ }
112+
82113 @ Test
83114 public void testKubectlLabelNamespacedResourceReceiveForbiddenShouldThrowException ()
84115 throws KubectlException {
@@ -134,6 +165,29 @@ public void testKubectlLabelClusterResourceShouldWork() throws KubectlException
134165 assertNotNull (labelledNode );
135166 }
136167
168+ @ Test
169+ public void testKubectlDeleteLabelClusterResourceShouldWork () throws KubectlException {
170+ wireMockRule .stubFor (
171+ get (urlPathEqualTo ("/api/v1/nodes/foo" ))
172+ .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
173+ wireMockRule .stubFor (
174+ put (urlPathEqualTo ("/api/v1/nodes/foo" ))
175+ .withRequestBody (
176+ matchingJsonPath ("$.metadata.labels" , equalToJson ("{ \" k1\" : \" null\" }" )))
177+ .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
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 (1 , getRequestedFor (urlPathEqualTo ("/api/v1/nodes/foo" )));
187+ wireMockRule .verify (1 , putRequestedFor (urlPathEqualTo ("/api/v1/nodes/foo" )));
188+ assertNotNull (unlabelledNode );
189+ }
190+
137191 @ Test
138192 public void testKubectlLabelClusterResourceReceiveForbiddenShouldThrowException ()
139193 throws KubectlException {
0 commit comments