Skip to content

Commit

Permalink
fix: add missing awaits (#1472)
Browse files Browse the repository at this point in the history
* refactor: silence expected console.error call

* fix: add missing access service awaits

* fix: add missing constraint validation await
  • Loading branch information
olav committed Apr 1, 2022
1 parent 1da3878 commit 9f7d878
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/db/access-store.ts
Expand Up @@ -181,7 +181,7 @@ export class AccessStore implements IAccessStore {
environment: permission.environment,
};
});
this.db.batchInsert(T.ROLE_PERMISSION, rows);
await this.db.batchInsert(T.ROLE_PERMISSION, rows);
}

async unlinkUserRoles(userId: number): Promise<void> {
Expand Down
8 changes: 8 additions & 0 deletions src/lib/db/event-store.test.ts
Expand Up @@ -2,6 +2,14 @@ import knex from 'knex';
import EventStore from './event-store';
import getLogger from '../../test/fixtures/no-logger';

beforeAll(() => {
getLogger.setMuteError(true);
});

afterAll(() => {
getLogger.setMuteError(false);
});

test('Trying to get events if db fails should yield empty list', async () => {
const db = knex({
client: 'pg',
Expand Down
6 changes: 3 additions & 3 deletions src/lib/services/access-service.ts
Expand Up @@ -406,7 +406,7 @@ export class AccessService {
const rolePermissions = role.permissions;
const newRole = await this.roleStore.create(baseRole);
if (rolePermissions) {
this.store.addEnvironmentPermissionsToRole(
await this.store.addEnvironmentPermissionsToRole(
newRole.id,
rolePermissions,
);
Expand All @@ -425,8 +425,8 @@ export class AccessService {
const rolePermissions = role.permissions;
const newRole = await this.roleStore.update(baseRole);
if (rolePermissions) {
this.store.wipePermissionsFromRole(newRole.id);
this.store.addEnvironmentPermissionsToRole(
await this.store.wipePermissionsFromRole(newRole.id);
await this.store.addEnvironmentPermissionsToRole(
newRole.id,
rolePermissions,
);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/feature-toggle-service.ts
Expand Up @@ -197,7 +197,7 @@ class FeatureToggleService {
}

if (oneOf(DATE_OPERATORS, operator)) {
validateDate(constraint.value);
await validateDate(constraint.value);
}

if (
Expand Down

0 comments on commit 9f7d878

Please sign in to comment.