From a75de6d1c2341215d0e348cafff3166aed9aa3f2 Mon Sep 17 00:00:00 2001 From: Scott Kay Date: Thu, 3 Dec 2020 15:57:42 -0500 Subject: [PATCH] Fix Missing Consumable Clock --- adapters/consumable/consumable.go | 1 + adapters/consumable/consumable_test.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/adapters/consumable/consumable.go b/adapters/consumable/consumable.go index 3288c686f84..15511c0ebb7 100644 --- a/adapters/consumable/consumable.go +++ b/adapters/consumable/consumable.go @@ -294,6 +294,7 @@ func extractExtensions(impression openrtb.Imp) (*adapters.ExtImpBidder, *openrtb // Builder builds a new instance of the Consumable adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &ConsumableAdapter{ + clock: realInstant{}, endpoint: config.Endpoint, } return bidder, nil diff --git a/adapters/consumable/consumable_test.go b/adapters/consumable/consumable_test.go index 3b55102b5de..56e1d626c7b 100644 --- a/adapters/consumable/consumable_test.go +++ b/adapters/consumable/consumable_test.go @@ -8,6 +8,7 @@ import ( "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" + "github.com/stretchr/testify/assert" ) func TestJsonSamples(t *testing.T) { @@ -18,11 +19,18 @@ func TestJsonSamples(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - setKnownTime(bidder) + assertClock(t, bidder) + replaceClockWithKnownTime(bidder) + adapterstest.RunJSONBidderTest(t, "consumable", bidder) } -func setKnownTime(bidder adapters.Bidder) { +func assertClock(t *testing.T, bidder adapters.Bidder) { + bidderConsumable, _ := bidder.(*ConsumableAdapter) + assert.NotNil(t, bidderConsumable.clock) +} + +func replaceClockWithKnownTime(bidder adapters.Bidder) { bidderConsumable, _ := bidder.(*ConsumableAdapter) bidderConsumable.clock = knownInstant(time.Date(2016, 1, 1, 12, 30, 15, 0, time.UTC)) }