Skip to content

Commit

Permalink
Merge 96c06e4 into backport/b-fix-api-panic-job-plan/marginally-commu…
Browse files Browse the repository at this point in the history
…nal-bedbug
  • Loading branch information
hc-github-team-nomad-core authored Jun 23, 2023
2 parents 5df9943 + 96c06e4 commit 95cdfba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ func (j *Jobs) PlanOpts(job *Job, opts *PlanOptions, q *WriteOptions) (*JobPlanR
if job == nil {
return nil, nil, errors.New("must pass non-nil job")
}
if job.ID == nil {
return nil, nil, errors.New("job is missing ID")
}

// Setup the request
req := &JobPlanRequest{
Expand Down
6 changes: 6 additions & 0 deletions api/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,12 @@ func TestJobs_Plan(t *testing.T) {
_, _, err = jobs.Plan(nil, true, nil)
must.Error(t, err)

// Check that passing a nil job ID fails
invalidJob := testJob()
invalidJob.ID = nil
_, _, err = jobs.Plan(invalidJob, true, nil)
must.Error(t, err)

// Make a plan request
planResp, wm, err := jobs.Plan(job, true, nil)
must.NoError(t, err)
Expand Down

0 comments on commit 95cdfba

Please sign in to comment.