Skip to content

Commit

Permalink
add UT
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishshinde-pubm committed Jul 24, 2024
1 parent 6359c8c commit bf7a45f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion adapters/ortbbidder/response_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func TestSetPrebidBidderResponse(t *testing.T) {
name string
bidderResponse map[string]any
bidderResponseBytes []byte
isDebugEnabled bool
responseParams map[string]bidderparams.BidderParamMapper
expectedError []error
expectedResponse map[string]any
Expand Down Expand Up @@ -184,7 +185,7 @@ func TestSetPrebidBidderResponse(t *testing.T) {
expectedError: []error{&errortypes.BadServerResponse{Message: "invalid bid found in bids array, bid:[invalid]"}},
},
{
name: "Valid bidder respone, no bidder params",
name: "Valid bidder respone, no bidder params, debug is disabled in request",
bidderResponseBytes: []byte(`{"id":"bid-resp-id","cur":"USD","seatbid":[{"seat":"test_bidder","bid":[{"id":"123"}]}]}`),
responseParams: map[string]bidderparams.BidderParamMapper{},
expectedError: []error{util.NewWarning("Potential issue encountered while setting the response parameter [bidType]")},
Expand All @@ -199,6 +200,23 @@ func TestSetPrebidBidderResponse(t *testing.T) {
},
},
},
{
name: "Valid bidder respone, no bidder params, debug is enabled in request",
bidderResponseBytes: []byte(`{"id":"bid-resp-id","cur":"USD","seatbid":[{"seat":"test_bidder","bid":[{"id":"123"}]}]}`),
responseParams: map[string]bidderparams.BidderParamMapper{},
isDebugEnabled: true,
expectedError: []error{util.NewWarning("invalid value sent by bidder at [bid.impid] for [bid.ext.prebid.type]")},
expectedResponse: map[string]any{
"Currency": "USD",
"Bids": []any{
map[string]any{
"Bid": map[string]any{
"id": "123",
},
},
},
},
},
{
name: "Valid bidder respone, no bidder params - bidtype populated",
bidderResponseBytes: []byte(`{"id":"bid-resp-id","cur":"USD","seatbid":[{"seat":"test_bidder","bid":[{"id":"123","mtype": 2}]}]}`),
Expand Down Expand Up @@ -326,6 +344,7 @@ func TestSetPrebidBidderResponse(t *testing.T) {
rb := &responseBuilder{
bidderResponse: tc.bidderResponse,
responseParams: tc.responseParams,
isDebugEnabled: tc.isDebugEnabled,
}
err := rb.setPrebidBidderResponse(tc.bidderResponseBytes)
assert.Equal(t, tc.expectedError, err)
Expand Down

0 comments on commit bf7a45f

Please sign in to comment.