Skip to content

Commit

Permalink
catch dropping collections
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTrunk committed Aug 18, 2024
1 parent 32c8a00 commit f751edc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-username: ssp-relay-user
mongodb-password: ssp-relay-password
mongodb-db: ssp-relay
- name: npm install
run: npm i
- name: Setup CI config
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/actionService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Action Service', () => {
const db = await serviceHelper.databaseConnection();
database = db.db(config.database.database);
actionCollection = config.collections.v1action;
await database.collection(actionCollection).drop();
await database.collection(actionCollection).drop().catch(() => {});
});

afterEach(function() {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/notificationService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ describe('Notification Service', () => {
});

// Currently there is a limitation in testing the firebase
it.skip('should return error when it sends key to firebase', async () => {
await database.collection(tokenCollection).drop()
it('should return error when it sends key to firebase', async () => {
await database.collection(tokenCollection).drop().catch(() => {});
await notificationService.sendNotificationKey(141, dataNoAction).catch(e => {
expect(e).to.not.be.null;
expect(e).to.not.be.undefined;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/socketService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Socket Service', () => {
const db = await serviceHelper.databaseConnection();
database = db.db(config.database.database);
socketCollection = config.collections.v1action;
await database.collection(socketCollection).drop();
await database.collection(socketCollection).drop().catch(() => {});;
});

afterEach(function() {
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/syncService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Sync Service', () => {
const db = await serviceHelper.databaseConnection();
database = db.db(config.database.database);
syncCollection = config.collections.v1sync;
await database.collection(syncCollection).drop();
await database.collection(syncCollection).drop().catch(() => {});
await database.collection(syncCollection).insertMany(testInsertV1Sync);
});

Expand Down Expand Up @@ -75,7 +75,7 @@ describe('Sync Service', () => {
});

it('should return error after database drop and id is invalid', async () => {
await database.collection(syncCollection).drop();
await database.collection(syncCollection).drop().catch(() => {});;
await syncService.getSync(141).catch((e) => assert.equal(e, 'Error: Sync 141 not found'));
});

Expand Down Expand Up @@ -151,7 +151,7 @@ describe('Sync Service', () => {
const db = await serviceHelper.databaseConnection();
database = db.db(config.database.database);
tokenCollection = config.collections.v1token;
await database.collection(tokenCollection).drop();
await database.collection(tokenCollection).drop().catch(() => {});;
await database.collection(tokenCollection).insertMany(testInsertV1Tokens);
});

Expand Down Expand Up @@ -183,7 +183,7 @@ describe('Sync Service', () => {
});

it('should return error after database drop and id is invalid', async () => {
await database.collection(tokenCollection).drop();
await database.collection(tokenCollection).drop().catch(() => {});;
await syncService.getTokens(141).catch((e) => assert.equal(e, 'Error: Sync 141 not found'));
});

Expand Down

0 comments on commit f751edc

Please sign in to comment.