adapterstest

package
v0.275.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BidOnTags

func BidOnTags(tags string) map[string]bool

BidOnTags Produces a map of TagIds, based on a comma separated strings. The map contains the list of tags to bid on.

func RunJSONBidderTest

func RunJSONBidderTest(t *testing.T, rootDir string, bidder adapters.Bidder)

RunJSONBidderTest is a helper method intended to unit test Bidders' adapters. It requires that:

  1. Bidders communicate with external servers over HTTP.
  2. 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:

  1. 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.

  2. 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 added in v0.261.0

func RunSingleJSONBidderTest(t *testing.T, bidder adapters.Bidder, path string, isJsonFile bool)

func SampleBid

func SampleBid(width *int64, height *int64, impId string, index int) openrtb2.Bid

SampleBid Produces a sample bid based on params given.

func VerifyBannerSize

func VerifyBannerSize(banner *openrtb2.Banner, expectedWidth int, expectedHeight int, t *testing.T)

VerifyBannerSize helper function to assert banner size

func VerifyBoolValue

func VerifyBoolValue(value bool, expected bool, t *testing.T)

VerifyBoolValue Helper function to assert bool equals.

func VerifyIntValue

func VerifyIntValue(value int, expected int, t *testing.T)

VerifyIntValue Helper function to assert Int equals.

func VerifyStringValue

func VerifyStringValue(value string, expected string, t *testing.T)

VerifyStringValue Helper function to assert string equals.

Types

type OrtbMockService

type OrtbMockService struct {
	Server          *httptest.Server
	LastBidRequest  *openrtb2.BidRequest
	LastHttpRequest *http.Request
}

OrtbMockService Represents a scaffolded OpenRTB service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL