From bf7a45f04157352a31dae75b2d65548d62cd3b0a Mon Sep 17 00:00:00 2001 From: "ashish.shinde" Date: Wed, 24 Jul 2024 09:11:09 +0530 Subject: [PATCH] add UT --- adapters/ortbbidder/response_builder_test.go | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/adapters/ortbbidder/response_builder_test.go b/adapters/ortbbidder/response_builder_test.go index b1e57b27e6c..7c598a812c5 100644 --- a/adapters/ortbbidder/response_builder_test.go +++ b/adapters/ortbbidder/response_builder_test.go @@ -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 @@ -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]")}, @@ -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}]}]}`), @@ -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)