Skip to content

Commit

Permalink
fix(tests): add missing assertions, bubble ORM connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Oct 13, 2019
1 parent f1bcc72 commit eceab17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ export class Bot extends BaseService<BotData> implements Service {
public async start() {
this.logger.info('starting bot');

const streamError = (err: Error) => {
this.logger.error(err, 'bot stream did not handle error');
};
const streamError = this.streamError.bind(this);
this.commands.subscribe((next) => this.receiveCommand(next).catch(streamError));
this.incoming.subscribe((next) => this.receive(next).catch(streamError));
this.outgoing.subscribe((next) => this.receiveMessage(next).catch(streamError));
Expand Down Expand Up @@ -252,6 +250,10 @@ export class Bot extends BaseService<BotData> implements Service {
}
}

protected streamError(err: Error) {
this.logger.error(err, 'bot stream did not handle error');
}

protected async findMessageTarget(msg: Message): Promise<void> {
for (const target of this.listeners) {
if (await target.check(msg)) {
Expand Down
1 change: 1 addition & 0 deletions src/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class Storage extends BaseService<StorageData> implements ServiceLifecycl
}
} catch (err) {
this.logger.error(err, 'error connecting to storage');
throw err;
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/utils/TestPicklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ describeLeaks('pick list', async () => {
for (let i = 0; i < PICK_REPS; i += 1) {
counter[list.pickOne()] += 1;
}

expect(counter.x).to.be.greaterThan(0);
expect(counter.y).to.be.greaterThan(0);
});

itLeaks('should pick some weighted items', async () => {
Expand Down

0 comments on commit eceab17

Please sign in to comment.