github.com/prebid/prebid-server/v2@v2.18.0/adapters/beachfront/beachfront_test.go (about)

     1  package beachfront
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/prebid/prebid-server/v2/adapters/adapterstest"
     7  	"github.com/prebid/prebid-server/v2/config"
     8  	"github.com/prebid/prebid-server/v2/openrtb_ext"
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestJsonSamples(t *testing.T) {
    13  	bidder, buildErr := Builder(openrtb_ext.BidderBeachfront, config.Adapter{
    14  		Endpoint:         `https://qa.beachrtb.com/prebid_display`,
    15  		ExtraAdapterInfo: `{"video_endpoint":"https://qa.beachrtb.com/bid.json?exchange_id"}`,
    16  	}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
    17  
    18  	if buildErr != nil {
    19  		t.Fatalf("Builder returned unexpected error %v", buildErr)
    20  	}
    21  
    22  	adapterstest.RunJSONBidderTest(t, "beachfronttest", bidder)
    23  }
    24  
    25  func TestExtraInfoDefaultWhenEmpty(t *testing.T) {
    26  	bidder, buildErr := Builder(openrtb_ext.BidderBeachfront, config.Adapter{
    27  		Endpoint:         `https://qa.beachrtb.com/prebid_display`,
    28  		ExtraAdapterInfo: ``,
    29  	}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
    30  
    31  	if buildErr != nil {
    32  		t.Fatalf("Builder returned unexpected error %v", buildErr)
    33  	}
    34  
    35  	bidderBeachfront, _ := bidder.(*BeachfrontAdapter)
    36  
    37  	assert.Equal(t, bidderBeachfront.extraInfo.VideoEndpoint, defaultVideoEndpoint)
    38  }
    39  
    40  func TestExtraInfoDefaultWhenNotSpecified(t *testing.T) {
    41  	bidder, buildErr := Builder(openrtb_ext.BidderBeachfront, config.Adapter{
    42  		Endpoint:         `https://qa.beachrtb.com/prebid_display`,
    43  		ExtraAdapterInfo: `{"video_endpoint":""}`,
    44  	}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
    45  
    46  	if buildErr != nil {
    47  		t.Fatalf("Builder returned unexpected error %v", buildErr)
    48  	}
    49  
    50  	bidderBeachfront, _ := bidder.(*BeachfrontAdapter)
    51  
    52  	assert.Equal(t, bidderBeachfront.extraInfo.VideoEndpoint, defaultVideoEndpoint)
    53  }
    54  
    55  func TestExtraInfoMalformed(t *testing.T) {
    56  	_, buildErr := Builder(openrtb_ext.BidderBeachfront, config.Adapter{
    57  		Endpoint:         `https://qa.beachrtb.com/prebid_display`,
    58  		ExtraAdapterInfo: `malformed`,
    59  	}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
    60  
    61  	assert.Error(t, buildErr)
    62  }