Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 authored Dec 31, 2024
1 parent 4a1c2bb commit 35afa05
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions handlers/bounty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@ func TestGetBountyByCreated(t *testing.T) {
Owner: owner,
Organization: workspace,
Workspace: workspace,
Proofs: []db.ProofOfWork{},
}
bountyResponses = append(bountyResponses, bountyResponse)
}
Expand All @@ -696,22 +695,19 @@ func TestGetBountyByCreated(t *testing.T) {
rctx := chi.NewRouteContext()
rctx.URLParams.Add("created", "1707991475")
req, _ := http.NewRequestWithContext(context.WithValue(context.Background(), chi.RouteCtxKey, rctx), http.MethodGet, "/created/1707991475", nil)

mockDb.On("GetProofsByBountyID", uint(1)).Return([]db.ProofOfWork{}).Once()

mockDb.On("GetBountyDataByCreated", createdStr).Return([]db.NewBounty{bounty}, nil).Once()
mockDb.On("GetPersonByPubkey", "owner-1").Return(db.Person{}).Once()
mockDb.On("GetPersonByPubkey", "user1").Return(db.Person{}).Once()
mockDb.On("GetWorkspaceByUuid", "work-1").Return(db.Workspace{}).Once()
mockDb.On("GetProofsByBountyID", bounty.ID).Return([]db.ProofOfWork{}).Once()

handler.ServeHTTP(rr, req)

var returnedBounty []db.BountyResponse
err := json.Unmarshal(rr.Body.Bytes(), &returnedBounty)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, rr.Code)
assert.NotEmpty(t, returnedBounty)

})
t.Run("Should return 404 if bounty is not present in db", func(t *testing.T) {
rr := httptest.NewRecorder()
Expand Down

0 comments on commit 35afa05

Please sign in to comment.