Skip to content

Commit

Permalink
internal/jobqueue/jobqueuetest/jobqueuetest: fix DB tests
Browse files Browse the repository at this point in the history
I got confused as the jobqueue interface is asymmetric.
It expects an object and returns a json.RawMessage
and when handing over to postgres this is abstracted
away by postgres
  • Loading branch information
schuellerf authored and croissanne committed Nov 19, 2024
1 parent f478f80 commit ca3f0a1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions internal/jobqueue/jobqueuetest/jobqueuetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,18 +776,15 @@ func testFail(t *testing.T, q jobqueue.JobQueue) {
),
}

testReason, err := json.Marshal(FailedJobErrorResult)
require.NoError(t, err)

// set a non-existing job to failed
err = q.FailJob(uuid.New(), testReason)
err := q.FailJob(uuid.New(), FailedJobErrorResult)
require.Error(t, err)

// Cancel a pending job
id := pushTestJob(t, q, "coralreef", nil, nil, "testchannel")
require.NotEmpty(t, id)

err = q.FailJob(id, testReason)
err = q.FailJob(id, FailedJobErrorResult)
require.NoError(t, err)

//nolint:golint,ineffassign
Expand All @@ -798,9 +795,10 @@ func testFail(t *testing.T, q jobqueue.JobQueue) {
type JobResult struct {
JobError *clienterrors.Error `json:"job_error"`
}

var r1 JobResult
err = json.Unmarshal(result, &r1)
require.NoError(t, err)
require.NoError(t, err, fmt.Sprintf("Error %v when trying to unmarshal %v", err, string(result)))

require.NotNil(t, r1)
require.Equal(t, "Test timeout reason", r1.JobError.Reason)
Expand Down

0 comments on commit ca3f0a1

Please sign in to comment.