Skip to content

Commit

Permalink
Check if map is nil before updating it (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
FriggaHel authored Apr 18, 2023
1 parent 6e0072f commit 68b7034
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/saucecloud/retry/junitretrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func (b *JunitRetrier) retryOnlyFailedClasses(reader job.Reader, jobOpts chan<-
Str("attempt", fmt.Sprintf("%d of %d", opt.Attempt+1, opt.Retries+1)).
Msgf(msg.RetryWithClasses, strings.Join(classes, ","))

if opt.TestOptions == nil {
opt.TestOptions = map[string]interface{}{}
}
opt.TestOptions["class"] = classes
jobOpts <- opt
}
Expand Down
39 changes: 39 additions & 0 deletions internal/saucecloud/retry/junitretrier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,45 @@ func TestAppsRetrier_Retry(t *testing.T) {
},
},
},
{
name: "Job retrying only failed suites if RDC + SmartRetry with no orig filters",
init: init{
RDCReader: &mocks.FakeJobReader{
ReadJobFn: nil,
PollJobFn: nil,
GetJobAssetFileNamesFn: nil,
GetJobAssetFileContentFn: func(ctx context.Context, jobID, fileName string) ([]byte, error) {
if jobID == "fake-job-id" && fileName == junit.JunitFileName {
return []byte("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<testsuite>\n <testcase classname=\"Demo.Class1\">\n <failure>ERROR</failure>\n </testcase>\n <testcase classname=\"Demo.Class1\"/>\n <testcase classname=\"Demo.Class2\"/>\n <testcase classname=\"Demo.Class3\"/>\n</testsuite>\n"), nil
}
return []byte{}, errors.New("unknown file")
},
},
RetryRDC: true,
},
args: args{
jobOpts: make(chan job.StartOptions),
opt: job.StartOptions{
DisplayName: "Dummy Test",
SmartRetry: job.SmartRetry{
FailedClassesOnly: true,
},
},
previous: job.Job{
ID: "fake-job-id",
IsRDC: true,
},
},
expected: job.StartOptions{
DisplayName: "Dummy Test",
TestOptions: map[string]interface{}{
"class": []string{"Demo.Class1"},
},
SmartRetry: job.SmartRetry{
FailedClassesOnly: true,
},
},
},
{
name: "Job not retrying if RDC and config is VDC + SmartRetry",
init: init{
Expand Down

0 comments on commit 68b7034

Please sign in to comment.