Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
Fix faulty server startup 'all failed' test, fix associated faulty ch…
Browse files Browse the repository at this point in the history
…eck.
  • Loading branch information
timoxley committed Feb 13, 2020
1 parent 2bab764 commit 5652043
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/server.js
Expand Up @@ -108,9 +108,10 @@ module.exports = class CommunityProductServer {
this.log(`Event ${num} of ${total} processed in ${Date.now() - startEventTime}ms, ${Math.round((num / total) * 100)}% complete.`)
}
this.log(`Finished playback of ${total} operator change events in ${Date.now() - startAllTime}ms.`)
if (numErrors && numErrors === total) {
const numCommunities = Object.keys(this.communities).length
if (numErrors && numErrors === numCommunities) {
// kill if all operators errored
throw new Error(`All ${total} operator changed events failed to process. Shutting down.`)
throw new Error(`All ${numCommunities} communities failed to start. Shutting down.`)
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/server.js
Expand Up @@ -202,6 +202,6 @@ describe("CommunityProductServer", function () {
server.getChannelFor.callsFake(async function () {
throw new Error("expected fail")
})
assert.rejects(() => server.start())
await assert.rejects(() => server.start())
})
})

0 comments on commit 5652043

Please sign in to comment.