Documentation ¶
Index ¶
- func BidOnTags(tags string) map[string]bool
- func RunJSONBidderTest(t *testing.T, rootDir string, bidder adapters.Bidder)
- func RunSingleJSONBidderTest(t *testing.T, bidder adapters.Bidder, path string, isJsonFile bool)
- func SampleBid(width *int64, height *int64, impId string, index int) openrtb2.Bid
- func VerifyBannerSize(banner *openrtb2.Banner, expectedWidth int, expectedHeight int, t *testing.T)
- func VerifyBoolValue(value bool, expected bool, t *testing.T)
- func VerifyIntValue(value int, expected int, t *testing.T)
- func VerifyStringValue(value string, expected string, t *testing.T)
- type OrtbMockService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BidOnTags ¶
BidOnTags Produces a map of TagIds, based on a comma separated strings. The map contains the list of tags to bid on.
func RunJSONBidderTest ¶
RunJSONBidderTest is a helper method intended to unit test Bidders' adapters. It requires that:
- Bidders communicate with external servers over HTTP.
- The HTTP request bodies are legal JSON.
Although the project does not require it, we _strongly_ recommend that all Bidders write tests using this. Doing so has the following benefits:
This includes some basic tests which confirm that your Bidder is "well-behaved" for all the input samples. For example, "no nil bids are allowed in the returned array". These tests are tedious to write, but help prevent bugs during auctions.
In the future, we plan to auto-generate documentation from the "exemplary" test files. Those docs will teach publishers how to use your Bidder, which should encourage adoption.
To use this method, create *.json files in the following directories:
adapters/{bidder}/{bidder}test/exemplary:
These show "ideal" BidRequests for your Bidder. If possible, configure your servers to return the same expected responses forever. If your server responds appropriately, our future auto-generated documentation can guarantee Publishers that your adapter works as documented.
adapters/{bidder}/{bidder}test/supplemental:
Fill this with *.json files which are useful test cases, but are not appropriate for public example docs. For example, a file in this directory might make sure that a mobile-only Bidder returns errors on non-mobile requests.
Then create a test in your adapters/{bidder}/{bidder}_test.go file like so:
func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "{bidder}test", instanceOfYourBidder) }
func RunSingleJSONBidderTest ¶
func VerifyBannerSize ¶
VerifyBannerSize helper function to assert banner size
func VerifyBoolValue ¶
VerifyBoolValue Helper function to assert bool equals.
func VerifyIntValue ¶
VerifyIntValue Helper function to assert Int equals.
Types ¶
type OrtbMockService ¶
type OrtbMockService struct { Server *httptest.Server LastBidRequest *openrtb2.BidRequest LastHttpRequest *http.Request }
OrtbMockService Represents a scaffolded OpenRTB service.