Skip to content

Commit

Permalink
fix: don't log success on error (#435)
Browse files Browse the repository at this point in the history
* fix: Only log finalize success if it was actually successful

It pains me to push this up without a failing test 😢

* fix: log finalize error to stderr

Adds a test to verify that the error is logged to stderr and that the finalize
log is not present due to the error
  • Loading branch information
Wil Wilsman committed Dec 11, 2019
1 parent d08317f commit 84ac23f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/build-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ export default class BuildService extends PercyClientService {
async finalize() {
if (!this.buildId) { return }

await this.percyClient.finalizeBuild(this.buildId).catch(logError)
this.logEvent('finalized')
try {
await this.percyClient.finalizeBuild(this.buildId)
this.logEvent('finalized')
} catch (err) {
logError(err)
}
}

async finalizeAll(): Promise<any> {
Expand Down
10 changes: 10 additions & 0 deletions test/acceptance/exec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ describe('percy exec', () => {
expect(proxy.requests['/builds/123/finalize']).toHaveLength(1)
})

it('logs finalization errors', async () => {
proxy.mock('/builds/:id/finalize', () => [404, { success: false }])

let [stdout, stderr] = await run('percy exec -- echo test')

expect(stdout).toHaveEntry('[percy] created build #4: <<build-url>>')
expect(stderr).toHaveEntry('[percy] StatusCodeError 404 - {"success":false}')
expect(stdout).not.toHaveEntry('[percy] finalized build #4: <<build-url>>')
})

describe('with snapshots', () => {
let dummy = setupDummyApp()

Expand Down

0 comments on commit 84ac23f

Please sign in to comment.