Skip to content

Commit

Permalink
fix log message not displaying when referencing missing bidder (prebi…
Browse files Browse the repository at this point in the history
…d#1737)

* fix log message not displaying when referencing missing bidder

* add test for missing bidder log message

* move test to adaptermanager_spec
  • Loading branch information
snapwich authored and mattpr committed Oct 31, 2017
1 parent 4f0f918 commit 00b8512
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,18 @@ exports.callBids = ({adUnits, cbTimeout}) => {
$$PREBID_GLOBAL$$._bidsRequested.push(bidderRequest);
_bidderRequests.push(bidderRequest);
}
} else {
utils.logError(`Adapter trying to be called which does not exist: ${bidderCode} adaptermanager.callBids`);
}
});

_bidderRequests.forEach(bidRequest => {
bidRequest.start = new Date().getTime();
const adapter = _bidderRegistry[bidRequest.bidderCode];
if (adapter) {
if (bidRequest.bids && bidRequest.bids.length !== 0) {
utils.logMessage(`CALLING BIDDER ======= ${bidRequest.bidderCode}`);
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidRequest);
adapter.callBids(bidRequest);
}
} else {
utils.logError(`Adapter trying to be called which does not exist: ${bidRequest.bidderCode} adaptermanager.callBids`);
if (bidRequest.bids && bidRequest.bids.length !== 0) {
utils.logMessage(`CALLING BIDDER ======= ${bidRequest.bidderCode}`);
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidRequest);
adapter.callBids(bidRequest);
}
})
};
Expand Down
24 changes: 24 additions & 0 deletions test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ var appnexusAdapterMock = {
};

describe('adapterManager tests', () => {
describe('callBids', () => {
beforeEach(() => {
sinon.stub(utils, 'logError');
});

afterEach(() => {
utils.logError.restore();
});

it('should log an error if a bidder is used that does not exist', () => {
const adUnits = [{
code: 'adUnit-code',
bids: [
{bidder: 'appnexus', params: {placementId: 'id'}},
{bidder: 'fakeBidder', params: {placementId: 'id'}}
]
}];

AdapterManager.callBids({adUnits});

sinon.assert.called(utils.logError);
});
});

describe('S2S tests', () => {
beforeEach(() => {
AdapterManager.setS2SConfig(CONFIG);
Expand Down

0 comments on commit 00b8512

Please sign in to comment.