github.com/prebid/prebid-server/v2@v2.18.0/adapters/alkimi/alkimi_test.go (about)

     1  package alkimi
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/prebid/prebid-server/v2/adapters"
     7  	"github.com/prebid/prebid-server/v2/adapters/adapterstest"
     8  	"github.com/prebid/prebid-server/v2/config"
     9  	"github.com/prebid/prebid-server/v2/openrtb_ext"
    10  	"github.com/stretchr/testify/assert"
    11  )
    12  
    13  const (
    14  	alkimiTestEndpoint = "https://exchange.alkimi-onboarding.com/server/bid"
    15  )
    16  
    17  func TestJsonSamples(t *testing.T) {
    18  	bidder, buildErr := Builder(
    19  		openrtb_ext.BidderAlkimi,
    20  		config.Adapter{Endpoint: alkimiTestEndpoint},
    21  		config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"},
    22  	)
    23  
    24  	if buildErr != nil {
    25  		t.Fatalf("Builder returned unexpected error %v", buildErr)
    26  	}
    27  
    28  	adapterstest.RunJSONBidderTest(t, "alkimitest", bidder)
    29  }
    30  
    31  func TestEndpointEmpty(t *testing.T) {
    32  	_, buildErr := Builder(openrtb_ext.BidderAlkimi, config.Adapter{
    33  		Endpoint: ""}, config.Server{ExternalUrl: alkimiTestEndpoint, GvlID: 1, DataCenter: "2"})
    34  	assert.Error(t, buildErr)
    35  }
    36  
    37  func TestEndpointMalformed(t *testing.T) {
    38  	_, buildErr := Builder(openrtb_ext.BidderAlkimi, config.Adapter{
    39  		Endpoint: " http://leading.space.is.invalid"}, config.Server{ExternalUrl: alkimiTestEndpoint, GvlID: 1, DataCenter: "2"})
    40  	assert.Error(t, buildErr)
    41  }
    42  
    43  func TestBuilder(t *testing.T) {
    44  	bidder, buildErr := buildBidder()
    45  	if buildErr != nil {
    46  		t.Fatalf("Failed to build bidder: %v", buildErr)
    47  	}
    48  	assert.NotNil(t, bidder)
    49  }
    50  
    51  func buildBidder() (adapters.Bidder, error) {
    52  	return Builder(
    53  		openrtb_ext.BidderAlkimi,
    54  		config.Adapter{Endpoint: alkimiTestEndpoint},
    55  		config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"},
    56  	)
    57  }