@@ -202,6 +202,42 @@ var _ = Describe("Kubectl client", func() {
202202 })
203203 })
204204
205+ Describe ("Kubectl label" , func () {
206+ var podPath string
207+ var nsFlag string
208+ BeforeEach (func () {
209+ podPath = filepath .Join (testContext .RepoRoot , "examples/pod.yaml" )
210+ By ("creating the pod" )
211+ nsFlag = fmt .Sprintf ("--namespace=%v" , ns )
212+ runKubectl ("create" , "-f" , podPath , nsFlag )
213+ checkPodsRunningReady (c , ns , []string {simplePodName }, podStartTimeout )
214+ })
215+ AfterEach (func () {
216+ cleanup (podPath , ns , simplePodSelector )
217+ })
218+
219+ It ("should update the label on a resource" , func () {
220+ labelName := "testing-label"
221+ labelValue := "testing-label-value"
222+
223+ By ("adding the label " + labelName + " with value " + labelValue + " to a pod" )
224+ runKubectl ("label" , "pods" , simplePodName , labelName + "=" + labelValue , nsFlag )
225+ By ("verifying the pod has the label " + labelName + " with the value " + labelValue )
226+ output := runKubectl ("get" , "pod" , simplePodName , "-L" , labelName , nsFlag )
227+ if ! strings .Contains (output , labelValue ) {
228+ Failf ("Failed updating label " + labelName + " to the pod " + simplePodName )
229+ }
230+
231+ By ("removing the label " + labelName + " of a pod" )
232+ runKubectl ("label" , "pods" , simplePodName , labelName + "-" , nsFlag )
233+ By ("verifying the pod doesn't have the label " + labelName )
234+ output = runKubectl ("get" , "pod" , simplePodName , "-L" , labelName , nsFlag )
235+ if strings .Contains (output , labelValue ) {
236+ Failf ("Failed removing label " + labelName + " of the pod " + simplePodName )
237+ }
238+ })
239+ })
240+
205241})
206242
207243func curl (addr string ) (string , error ) {
0 commit comments