Skip to content

Commit

Permalink
Metax: Update BidVideo tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kehan Pan <kehan.pan@metaxsoft.com>
  • Loading branch information
metax-kehan committed Dec 13, 2024
1 parent 06155ef commit 58f423b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
38 changes: 23 additions & 15 deletions adapters/metax/metax_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,35 +150,43 @@ func TestGetBidType(t *testing.T) {

func TestGetBidVideo(t *testing.T) {
tests := []struct {
bid *openrtb2.Bid
bidvideo openrtb_ext.ExtBidPrebidVideo
description string
bid *openrtb2.Bid
bidvideo openrtb_ext.ExtBidPrebidVideo
}{
{
&openrtb2.Bid{Cat: []string{"IAB1-1"}},
openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 0},
description: "One category, no duration",
bid: &openrtb2.Bid{Cat: []string{"IAB1-1"}},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 0},
},
{
&openrtb2.Bid{Cat: []string{"IAB1-1", "IAB1-2"}},
openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 0},
description: "Two categories and use the first, no duration",
bid: &openrtb2.Bid{Cat: []string{"IAB1-1", "IAB1-2"}},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 0},
},
{
&openrtb2.Bid{Cat: []string{}},
openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "", Duration: 0},
description: "No category, no duration",
bid: &openrtb2.Bid{Cat: []string{}},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "", Duration: 0},
},
{
&openrtb2.Bid{Cat: nil},
openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "", Duration: 0},
description: "No category(nil), no duration",
bid: &openrtb2.Bid{Cat: nil},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "", Duration: 0},
},
{
&openrtb2.Bid{Cat: []string{"IAB1-1", "IAB1-2"}, Dur: 15},
openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 15},
description: "Two categories and use the first, duration is 15",
bid: &openrtb2.Bid{Cat: []string{"IAB1-1", "IAB1-2"}, Dur: 15},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 15},
},
}

for _, test := range tests {
bidVideo := getBidVideo(test.bid)
assert.Equal(t, test.bidvideo.PrimaryCategory, bidVideo.PrimaryCategory)
assert.Equal(t, test.bidvideo.Duration, bidVideo.Duration)
t.Run(test.description, func(t *testing.T) {
bidVideo := getBidVideo(test.bid)
assert.Equal(t, test.bidvideo.PrimaryCategory, bidVideo.PrimaryCategory)
assert.Equal(t, test.bidvideo.Duration, bidVideo.Duration)
})
}
}

Expand Down
20 changes: 17 additions & 3 deletions adapters/metax/metaxtest/exemplary/simple-app-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@
"crid": "test-crid",
"w": 1024,
"h": 576,
"mtype": 2
"mtype": 2,
"dur": 15,
"cat": [
"IAB1-5",
"IAB1-6"
]
}
]
}
Expand All @@ -120,9 +125,18 @@
"crid": "test-crid",
"w": 1024,
"h": 576,
"mtype": 2
"mtype": 2,
"dur": 15,
"cat": [
"IAB1-5",
"IAB1-6"
]
},
"type": "video"
"type": "video",
"video": {
"duration": 15,
"primary_category": "IAB1-5"
}
}
]
}
Expand Down

0 comments on commit 58f423b

Please sign in to comment.