From b691d63dfd1d2b572d53c675ca979be7c6ccb3d8 Mon Sep 17 00:00:00 2001 From: Abdul Wahab Date: Mon, 19 Feb 2024 16:09:55 +0500 Subject: [PATCH] Addressed changes --- handlers/bounty.go | 6 +++--- handlers/bounty_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/handlers/bounty.go b/handlers/bounty.go index 81243f04d..3c3f186ae 100644 --- a/handlers/bounty.go +++ b/handlers/bounty.go @@ -21,14 +21,14 @@ import ( type bountyHandler struct { httpClient HttpClient db db.Database - generateBountyHandler func(bounties []db.Bounty) []db.BountyResponse + generateBountyResponse func(bounties []db.Bounty) []db.BountyResponse } func NewBountyHandler(httpClient HttpClient, db db.Database) *bountyHandler { return &bountyHandler{ httpClient: httpClient, db: db, - generateBountyHandler: GenerateBountyResponse, + generateBountyResponse: GenerateBountyResponse, } } @@ -120,7 +120,7 @@ func (h *bountyHandler) GetBountyByCreated(w http.ResponseWriter, r *http.Reques w.WriteHeader(http.StatusBadRequest) fmt.Println("Error", err) } else { - var bountyResponse []db.BountyResponse = h.generateBountyHandler(bounties) + var bountyResponse []db.BountyResponse = h.generateBountyResponse(bounties) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(bountyResponse) } diff --git a/handlers/bounty_test.go b/handlers/bounty_test.go index 5bb7c6f00..83f6bb7db 100644 --- a/handlers/bounty_test.go +++ b/handlers/bounty_test.go @@ -453,14 +453,14 @@ func TestDeleteBounty(t *testing.T) { func TestGetBountyByCreated(t *testing.T) { ctx := context.WithValue(context.Background(), auth.ContextKey, "test-key") mockDb := dbMocks.NewDatabase(t) - mockGenerateBountyHandler := func(bounties []db.Bounty) []db.BountyResponse { + mockGenerateBountyResponse := func(bounties []db.Bounty) []db.BountyResponse { return []db.BountyResponse{} // Mocked response } mockHttpClient := mocks.NewHttpClient(t) bHandler := NewBountyHandler(mockHttpClient, mockDb) t.Run("Should return bounty by its created value", func(t *testing.T) { - bHandler.generateBountyHandler = mockGenerateBountyHandler + bHandler.generateBountyResponse = mockGenerateBountyResponse expectedBounty := []db.Bounty{{ ID: 1,