Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nader-ziada authored and tekton-robot committed May 21, 2019
1 parent e33766b commit ea5cc07
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1alpha1/task_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ func (ts *TaskSpec) SetDefaults(ctx context.Context) {
}
}
}
return
}
35 changes: 31 additions & 4 deletions pkg/reconciler/v1alpha1/taskrun/resources/image_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestAddOutputImageDigestExporter(t *testing.T) {
}
}

func TestUpdateTaskRunStatus(t *testing.T) {
func TestUpdateTaskRunStatus_withValidJson(t *testing.T) {
for _, c := range []struct {
desc string
podLog []byte
Expand Down Expand Up @@ -237,7 +237,31 @@ func TestUpdateTaskRunStatus(t *testing.T) {
Name: "source-image",
Digest: "sha256:1234",
}},
}, {
}} {
t.Run(c.desc, func(t *testing.T) {
names.TestingSeed()
c.taskRun.Status.SetCondition(&apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
})
err := UpdateTaskRunStatusWithResourceResult(c.taskRun, c.podLog)
if err != nil {
t.Errorf("UpdateTaskRunStatusWithResourceResult failed with error: %s", err)
}
if d := cmp.Diff(c.taskRun.Status.ResourcesResult, c.want); d != "" {
t.Errorf("post build steps mismatch: %s", d)
}
})
}
}

func TestUpdateTaskRunStatus_withInvalidJson(t *testing.T) {
for _, c := range []struct {
desc string
podLog []byte
taskRun *v1alpha1.TaskRun
want []v1alpha1.PipelineResourceResult
}{{
desc: "image resource exporter with malformed json output",
podLog: []byte("extralogscamehere[{\"name\":\"source-image\",\"digest\":\"sha256:1234\"}]"),
taskRun: &v1alpha1.TaskRun{
Expand Down Expand Up @@ -282,9 +306,12 @@ func TestUpdateTaskRunStatus(t *testing.T) {
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
})
UpdateTaskRunStatusWithResourceResult(c.taskRun, c.podLog)
err := UpdateTaskRunStatusWithResourceResult(c.taskRun, c.podLog)
if err == nil {
t.Error("UpdateTaskRunStatusWithResourceResult expected to fail with error")
}
if d := cmp.Diff(c.taskRun.Status.ResourcesResult, c.want); d != "" {
t.Fatalf("post build steps mismatch: %s", d)
t.Errorf("post build steps mismatch: %s", d)
}
})
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/reconciler/v1alpha1/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,10 @@ func TestUpdateStatusFromPod(t *testing.T) {
}}

for _, r := range rs {
pipelineResourceInformer.Informer().GetIndexer().Add(r)
err := pipelineResourceInformer.Informer().GetIndexer().Add(r)
if err != nil {
t.Errorf("pipelineResourceInformer.Informer().GetIndexer().Add(r) failed with err: %s", err)
}
}

now := metav1.Now()
Expand Down

0 comments on commit ea5cc07

Please sign in to comment.