Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Missing Consumable Clock #1610

Merged
merged 1 commit into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
}