From ca3f0a190fbdc0331bfaefca248e567773800989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=BCller?= Date: Thu, 7 Nov 2024 14:24:10 +0100 Subject: [PATCH] internal/jobqueue/jobqueuetest/jobqueuetest: fix DB tests 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 --- internal/jobqueue/jobqueuetest/jobqueuetest.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/jobqueue/jobqueuetest/jobqueuetest.go b/internal/jobqueue/jobqueuetest/jobqueuetest.go index 27c0eb2ab8..930a076f55 100644 --- a/internal/jobqueue/jobqueuetest/jobqueuetest.go +++ b/internal/jobqueue/jobqueuetest/jobqueuetest.go @@ -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 @@ -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)