Skip to content

Commit

Permalink
Fix Missing Consumable Clock (prebid#1610)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxNode authored and Dan Barnett committed May 11, 2021
1 parent a64dfce commit ef1d16b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions adapters/consumable/consumable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions adapters/consumable/consumable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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))
}

0 comments on commit ef1d16b

Please sign in to comment.