Skip to content

Commit

Permalink
test: Fix some logging related test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
trodrigues committed Feb 29, 2016
1 parent 1a973b8 commit fc8cc69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 7 additions & 4 deletions lib/push/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ export function processAssets (context, assets) {
return asset
})
}))
.then(() => asset, err => {
log.warn('Error processing', asset.fields.file)
throw err
})
.then(
() => asset,
err => {
log.warn('Error processing', asset.fields.file)
throw err
}
)
})
}

Expand Down
10 changes: 6 additions & 4 deletions test/push/assets-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const logMock = {

function setup () {
logMock.info.reset()
logMock.warn.reset()
assets.__Rewire__('log', logMock)
}

Expand All @@ -36,18 +37,19 @@ test('Process assets', t => {
})
})

test('Fails to process assets', t => {
test.only('Fails to process assets', t => {
setup()
const space = {
processAssetFile: sinon.stub().returns(Promise.reject({}))
processAssetFile: sinon.stub().returns(Promise.reject({name: 'ProcessingError'}))
}
assets.processAssets({space: space}, [
{ sys: {id: '123'}, fields: {file: {'en-US': 'file object', 'en-GB': {}}} },
{ sys: {id: '456'}, fields: {file: {'en-US': 'file object', 'en-GB': {}}} }
])
.catch(response => {
.catch((response, r2, r3) => {
console.log('in test', response, r2, r3)
t.equals(space.processAssetFile.callCount, 4, 'processes assets')
t.equals(logMock.warn.callCount, 1, 'logs processing failure of assets')
t.equals(logMock.warn.callCount, 2, 'logs processing failure of assets')
teardown()
t.end()
})
Expand Down

0 comments on commit fc8cc69

Please sign in to comment.