Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
feat(test): add test for get dlq job handler
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekv24 committed Oct 23, 2023
1 parent 0a3d7fc commit 9d474fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/server/v1/dlq/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (*Handler) createDlqJob(w http.ResponseWriter, _ *http.Request) {
})
}

func (h *Handler) getDlqJob(w http.ResponseWriter, r *http.Request) {
func (h *Handler) GetDlqJob(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
jobURN := h.jobURN(r)

Expand Down
17 changes: 17 additions & 0 deletions internal/server/v1/dlq/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,20 @@ func TestErrorFromFirehoseResource(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "test-error", expectedMap["cause"])
}

func TestErrorFromDlqJob(t *testing.T) {
eService := &mocks.ResourceServiceClient{}
gClient := &mocks.BlobStorageClient{}
handler := dlq.NewHandler(dlq.NewService(eService, gClient, &dlq.DlqJobConfig{}))
httpWriter := &testHTTPWriter{}
httpRequest := &http.Request{}
eService.On(
"GetResource",
context.Background(),
mock.Anything).Return(nil, fmt.Errorf("test-dlq-error"))
handler.GetDlqJob(httpWriter, httpRequest)
expectedMap := make(map[string]interface{})
err := json.Unmarshal([]byte(httpWriter.messages[0]), &expectedMap)
require.NoError(t, err)
assert.Equal(t, "error getting entropy resource: test-dlq-error", expectedMap["cause"])
}
2 changes: 1 addition & 1 deletion internal/server/v1/dlq/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Routes(
return func(r chi.Router) {
r.Get("/firehose/{firehose_urn}", handler.ListFirehoseDLQ)
r.Get("/jobs", handler.listDlqJobs)
r.Get("/jobs/{job_urn}", handler.getDlqJob)
r.Get("/jobs/{job_urn}", handler.GetDlqJob)
r.Post("/jobs", handler.createDlqJob)
}
}

0 comments on commit 9d474fc

Please sign in to comment.