Skip to content

Commit

Permalink
Add a test to ensure that labels are updated as a part of TaskRun
Browse files Browse the repository at this point in the history
reconciliation.
  • Loading branch information
R2wenD2 authored and tekton-robot committed Jul 7, 2020
1 parent 3243489 commit b117cd7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/reconciler/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,8 @@ func makePod(taskRun *v1beta1.TaskRun, task *v1beta1.Task) (*corev1.Pod, error)
}

func TestReconcilePodUpdateStatus(t *testing.T) {
taskRun := tb.TaskRun("test-taskrun-run-success", tb.TaskRunNamespace("foo"), tb.TaskRunSpec(tb.TaskRunTaskRef("test-task")))
const taskLabel = "test-task"
taskRun := tb.TaskRun("test-taskrun-run-success", tb.TaskRunNamespace("foo"), tb.TaskRunSpec(tb.TaskRunTaskRef(taskLabel)))

pod, err := makePod(taskRun, simpleTask)
if err != nil {
Expand Down Expand Up @@ -1808,6 +1809,14 @@ func TestReconcilePodUpdateStatus(t *testing.T) {
t.Fatalf("Did not get expected condition %s", diff.PrintWantGot(d))
}

trLabel, ok := newTr.ObjectMeta.Labels[taskNameLabelKey]
if !ok {
t.Errorf("Labels were not added to task run")
}
if ld := cmp.Diff(taskLabel, trLabel); ld != "" {
t.Errorf("Did not get expected label %s", diff.PrintWantGot(ld))
}

// update pod status and trigger reconcile : build is completed
pod.Status = corev1.PodStatus{
Phase: corev1.PodSucceeded,
Expand Down

0 comments on commit b117cd7

Please sign in to comment.