Skip to content

Commit 4ff0cc7

Browse files
committed
Review: Add default case to all select block
The default case will throw an error of the failure
1 parent 1ccb031 commit 4ff0cc7

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

pkg/jobs/common_job_list_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func TestCommonJobList_SelectedJobsProduceFiles(t *testing.T) {
5353
}
5454
case <-ctx.Done():
5555
t.Fatalf("job %s timed out", job.Name)
56+
57+
default:
58+
// No result yet, which is unexpected since we set a timeout above
59+
t.Fatalf("job %s did not return result", job.Name)
5660
}
5761
}
5862
}

pkg/jobs/ngx_job_list_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ func TestNGXJobList_ExecNginxT(t *testing.T) {
7373
}
7474
case <-time.After(time.Second):
7575
t.Fatal("job execution timed out")
76+
77+
default:
78+
t.Fatalf("job %s did not return result", job.Name)
7679
}
7780
}
7881

pkg/jobs/nic_job_list_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ func TestNICJobList_ExecJobs(t *testing.T) {
6969
}
7070
case <-time.After(time.Second):
7171
t.Errorf("Job %s timed out", job.Name)
72+
73+
default:
74+
t.Errorf("Job %s did not return result", job.Name)
7275
}
7376
}
7477
}
@@ -101,6 +104,9 @@ func TestNICJobList_CRDObjects(t *testing.T) {
101104
}
102105
case <-time.After(time.Second):
103106
t.Errorf("CRD job timed out")
107+
108+
default:
109+
t.Errorf("CRD job %s did not return result", job.Name)
104110
}
105111
}
106112
}
@@ -180,6 +186,9 @@ func TestNICJobList_CRDObjects_QueryFailure(t *testing.T) {
180186

181187
case <-ctx.Done():
182188
t.Fatal("CRD job timed out")
189+
190+
default:
191+
t.Fatalf("CRD job %s did not return result", crdJob.Name)
183192
}
184193
}
185194

@@ -488,6 +497,9 @@ func TestNICJobList_CommandExecutionFailure(t *testing.T) {
488497

489498
case <-ctx.Done():
490499
t.Fatalf("Job %s timed out", tt.jobName)
500+
501+
default:
502+
t.Fatalf("Job %s did not return result", tt.jobName)
491503
}
492504
})
493505
}
@@ -554,5 +566,8 @@ func TestNICJobList_CollectProductPlatformInfo_JSONMarshalFailure(t *testing.T)
554566

555567
case <-ctx.Done():
556568
t.Fatal("Job timed out")
569+
570+
default:
571+
t.Fatalf("Job %s did not return result", job.Name)
557572
}
558573
}

pkg/jobs/nim_job_list_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func TestNIMJobList_ExecJobs(t *testing.T) {
103103
}
104104
case <-time.After(2 * time.Second):
105105
t.Errorf("Job %s timed out", job.Name)
106+
107+
default:
108+
t.Errorf("Job %s did not return result", job.Name)
106109
}
107110
}
108111
}
@@ -135,6 +138,9 @@ func TestNIMJobList_ExcludeFlags(t *testing.T) {
135138
}
136139
case <-time.After(time.Second):
137140
t.Fatal("Job exec-clickhouse-data timed out")
141+
142+
default:
143+
t.Fatalf("Job %s did not return result", job.Name)
138144
}
139145
}
140146
}
@@ -152,6 +158,9 @@ func TestNIMJobList_ExcludeFlags(t *testing.T) {
152158
}
153159
case <-time.After(time.Second):
154160
t.Fatal("Job exec-dqlite-dump timed out")
161+
162+
default:
163+
t.Fatalf("Job %s did not return result", job.Name)
155164
}
156165
}
157166
}

0 commit comments

Comments
 (0)