Skip to content

Commit

Permalink
Merge pull request #66 from htcondor/yqu/no_crash_for_fail_jobad
Browse files Browse the repository at this point in the history
Update parse_job_ad() and add TestParseJobAd()
  • Loading branch information
djw8605 authored May 23, 2023
2 parents 634752b + 9f51127 commit 36c093d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func parse_job_ad(payload payloadStruct) { // TODO: needs the payload

b, err := os.ReadFile(filename)
if err != nil {
log.Fatal(err)
log.Warningln("Can not read .job.ad file", err)
}

// Get all matches from file
Expand Down
10 changes: 10 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,13 @@ func FuzzGetTokenName(f *testing.F) {
assert.Equal(t, strings.ToLower(orig), tokenName, "URL: "+urlString+"URL String: "+url.String()+" Scheme: "+url.Scheme)
})
}

func TestParseNoJobAd(t *testing.T) {
// Job ad file does not exist
tempDir := t.TempDir()
path := filepath.Join(tempDir, ".job.ad")
os.Setenv("_CONDOR_JOB_AD", path)

payload := payloadStruct{}
parse_job_ad(payload)
}

0 comments on commit 36c093d

Please sign in to comment.