Skip to content

Commit

Permalink
udpate ut
Browse files Browse the repository at this point in the history
  • Loading branch information
mwang-sticky committed Apr 30, 2024
1 parent 61830b1 commit 9924f99
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 88 deletions.
4 changes: 2 additions & 2 deletions adapters/freewheelssp/freewheelssp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

type adapter struct {
Endpoint string
endpoint string
}

func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
Expand Down Expand Up @@ -53,7 +53,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E

requestData := &adapters.RequestData{
Method: "POST",
Uri: a.Endpoint,
Uri: a.endpoint,
Body: requestJSON,
Headers: headers,
ImpIDs: openrtb_ext.GetImpIDs(request.Imp),
Expand Down
80 changes: 0 additions & 80 deletions adapters/freewheelssp/freewheelssp_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package freewheelssp

import (
"github.com/prebid/prebid-server/v2/adapters"
"net/http"
"testing"

"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v2/adapters/adapterstest"
"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/openrtb_ext"
"github.com/stretchr/testify/assert"
)

func TestJsonSamples(t *testing.T) {
Expand All @@ -22,79 +18,3 @@ func TestJsonSamples(t *testing.T) {

adapterstest.RunJSONBidderTest(t, "freewheelssptest", bidder)
}

func TestFreewheelAdapter_MakeBids(t *testing.T) {
type fields struct {
URI string
}
type args struct {
internalRequest *openrtb2.BidRequest
externalRequest *adapters.RequestData
response *adapters.ResponseData
}
tests := []struct {
name string
fields fields
args args
wantErr []error
wantResp *adapters.BidderResponse
}{
{
name: "happy path, valid response with all bid params",
args: args{
response: &adapters.ResponseData{
StatusCode: http.StatusOK,
Body: []byte(`{"id": "test-request-id", "seatbid":[{"seat": "StickyAdsTv", "bid":[{"id": "7706636740145184841", "impid": "test-imp-id", "price": 0.500000, "adid": "29681110", "adm": "some-test-ad", "adomain":["freewheel.com"], "crid": "29681110", "dealid": "testdeal", "cat": ["IAB10"], "dur": 14 },
{"id": "7706636740145184841", "impid": "test-imp-id", "price": 0.500000, "adid": "29681110", "adm": "some-test-ad", "adomain":["freewheel.com"], "crid": "29681110", "dealid": "testdeal", "Dur":10}]}], "bidid": "5778926625248726496", "cur": "USD"}`),
},
},
wantErr: nil,
wantResp: &adapters.BidderResponse{
Bids: []*adapters.TypedBid{
{
Bid: &openrtb2.Bid{
ID: "7706636740145184841",
ImpID: "test-imp-id",
Price: 0.500000,
AdID: "29681110",
AdM: "some-test-ad",
ADomain: []string{"freewheel.com"},
CrID: "29681110",
DealID: "testdeal",
Cat: []string{"IAB10"},
Dur: 14,
},
BidType: openrtb_ext.BidTypeVideo,
BidVideo: &openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB10", Duration: 14},
},
{
Bid: &openrtb2.Bid{
ID: "7706636740145184841",
ImpID: "test-imp-id",
Price: 0.500000,
AdID: "29681110",
AdM: "some-test-ad",
ADomain: []string{"freewheel.com"},
CrID: "29681110",
DealID: "testdeal",
Dur: 10,
},
BidType: openrtb_ext.BidTypeVideo,
BidVideo: &openrtb_ext.ExtBidPrebidVideo{Duration: 10},
},
},
Currency: "USD",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := &adapter{
Endpoint: tt.fields.URI,
}
gotResp, gotErr := a.MakeBids(tt.args.internalRequest, tt.args.externalRequest, tt.args.response)
assert.Equal(t, tt.wantErr, gotErr)
assert.Equal(t, tt.wantResp, gotResp)
})
}
}
29 changes: 23 additions & 6 deletions adapters/freewheelssp/freewheelssptest/exemplary/multi-imp.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@
"adid": "7857",
"adm": "<?xml version='1.0' encoding='UTF-8'?><VAST version='2.0'></VAST>",
"cid": "4001",
"crid": "7857"
"crid": "7857",
"adomain":["freewheel.com"],
"cat": ["IAB10"],
"dur": 14
},
{
"id": "12346_freewheelssp-test_2",
Expand All @@ -98,7 +101,9 @@
"adid": "7933",
"adm": "<?xml version='1.0' encoding='UTF-8'?><VAST version='2.0'></VAST>",
"cid": "3476",
"crid": "7933"
"crid": "7933",
"adomain":["freewheel.com"],
"dur":10
}
],
"seat": "freewheelsspTv"
Expand All @@ -123,9 +128,16 @@
"adid": "7857",
"adm": "<?xml version='1.0' encoding='UTF-8'?><VAST version='2.0'></VAST>",
"cid": "4001",
"crid": "7857"
"crid": "7857",
"adomain":["freewheel.com"],
"cat": ["IAB10"],
"dur": 14
},
"type": "video"
"type": "video",
"video" : {
"duration" : 14,
"primary_category": "IAB10"
}
},
{
"bid": {
Expand All @@ -135,9 +147,14 @@
"adid": "7933",
"adm": "<?xml version='1.0' encoding='UTF-8'?><VAST version='2.0'></VAST>",
"cid": "3476",
"crid": "7933"
"crid": "7933",
"adomain":["freewheel.com"],
"dur":10
},
"type": "video"
"type": "video",
"video" : {
"duration" : 10
}
}
]
}
Expand Down

0 comments on commit 9924f99

Please sign in to comment.