github.com/prebid/prebid-server/v2@v2.18.0/adapters/adnuntius/adnuntius_test.go (about)

     1  package adnuntius
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/prebid/prebid-server/v2/adapters"
     8  	"github.com/prebid/prebid-server/v2/adapters/adapterstest"
     9  	"github.com/prebid/prebid-server/v2/config"
    10  	"github.com/prebid/prebid-server/v2/openrtb_ext"
    11  	"github.com/stretchr/testify/assert"
    12  )
    13  
    14  func TestJsonSamples(t *testing.T) {
    15  	bidder, buildErr := Builder(openrtb_ext.BidderAdnuntius, config.Adapter{
    16  		Endpoint:         "http://whatever.url",
    17  		ExtraAdapterInfo: "http://gdpr.url",
    18  	},
    19  		config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
    20  
    21  	if buildErr != nil {
    22  		t.Fatalf("Builder returned unexpected error %v", buildErr)
    23  	}
    24  	assertTzo(t, bidder)
    25  	AssignDefaultValues(bidder)
    26  
    27  	adapterstest.RunJSONBidderTest(t, "adnuntiustest", bidder)
    28  }
    29  
    30  func assertTzo(t *testing.T, bidder adapters.Bidder) {
    31  	bidderAdnuntius, _ := bidder.(*adapter)
    32  	assert.NotNil(t, bidderAdnuntius.time)
    33  }
    34  
    35  // FakeTime implements the Time interface
    36  type FakeTime struct {
    37  	time time.Time
    38  }
    39  
    40  func (ft *FakeTime) Now() time.Time {
    41  	return ft.time
    42  }
    43  
    44  func AssignDefaultValues(bidder adapters.Bidder) {
    45  	bidderAdnuntius, _ := bidder.(*adapter)
    46  	bidderAdnuntius.time = &FakeTime{
    47  		time: time.Date(2016, 1, 1, 12, 30, 15, 0, time.UTC),
    48  	}
    49  }