Skip to content

Commit

Permalink
Addressed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdulWahab3181 committed Feb 19, 2024
1 parent 9d4a2fb commit b691d63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions handlers/bounty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b691d63

Please sign in to comment.