Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions operator/controllers/execution/scans/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const (

// checkIfAllJobsCompleted returns `completed` if all jobs of the given jobList are in a successful state, incompleted otherwise.
func checkIfAllJobsCompleted(jobs *batch.JobList) jobCompletionType {
if len(jobs.Items) == 0 {
return incomplete
}

hasCompleted := true

for _, job := range jobs.Items {
Expand Down
11 changes: 11 additions & 0 deletions operator/controllers/execution/scans/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func TestScanControllers(t *testing.T) {

var _ = Describe("ScanControllers", func() {
Context("checkIfAllJobsCompleted", func() {
It("should return incomplete if no jobs were found", func() {
jobs := &batch.JobList{}

Expect(checkIfAllJobsCompleted(jobs)).To(Equal(incomplete))
})

It("should return completed if all jobs succeeded", func() {
jobs := &batch.JobList{
Items: []batch.Job{
Expand Down Expand Up @@ -61,6 +67,11 @@ var _ = Describe("ScanControllers", func() {
It("should return failed if any job exceeded backoff limit", func() {
jobs := &batch.JobList{
Items: []batch.Job{
{
Status: batch.JobStatus{
Succeeded: 1,
},
},
{
Status: batch.JobStatus{
Failed: 1,
Expand Down