Skip to content

Commit

Permalink
refactor: Rename roleName->hasuraRoleName to avoid confusion with…
Browse files Browse the repository at this point in the history
… PG role
  • Loading branch information
morgsmccauley committed Jun 28, 2023
1 parent d61a356 commit bad27cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions indexer-js-queue-handler/provisioner.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ export default class Provisioner {
}
}

async addPermissionsToTables(schemaName, tableNames, roleName, permissions) {
async addPermissionsToTables(schemaName, tableNames, hasuraRoleName, permissions) {
try {
await this.hasuraClient.addPermissionsToTables(
schemaName,
tableNames,
roleName,
hasuraRoleName,
['select', 'insert', 'update', 'delete']
);
} catch (error) {
Expand All @@ -58,7 +58,7 @@ export default class Provisioner {
}
}

async createAuthenticatedEndpoint(schemaName, roleName, migration) {
async createAuthenticatedEndpoint(schemaName, hasuraRoleName, migration) {
try {
await this.runMigrations(schemaName, migration);

Expand All @@ -67,14 +67,14 @@ export default class Provisioner {

await this.trackForeignKeyRelationships(schemaName);

await this.addPermissionsToTables(schemaName, tableNames, roleName, ['select', 'insert', 'update', 'delete']);
await this.addPermissionsToTables(schemaName, tableNames, hasuraRoleName, ['select', 'insert', 'update', 'delete']);
} catch (error) {
throw new VError(
{
cause: error,
info: {
schemaName,
roleName,
hasuraRoleName,
migration,
}
},
Expand Down
16 changes: 8 additions & 8 deletions indexer-js-queue-handler/provisioner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ describe('Provision', () => {
const provisioner = new Provisioner(hasuraClient);

const schemaName = 'schema';
const roleName = 'role';
const hasuraRoleName = 'role';
const migration = 'CREATE TABLE blocks (height numeric)';
await provisioner.createAuthenticatedEndpoint(schemaName, roleName, migration);
await provisioner.createAuthenticatedEndpoint(schemaName, hasuraRoleName, migration);

expect(hasuraClient.runMigrations).toBeCalledWith(schemaName, migration);
expect(hasuraClient.getTableNames).toBeCalledWith(schemaName);
expect(hasuraClient.trackTables).toBeCalledWith(schemaName, tableNames);
expect(hasuraClient.addPermissionsToTables).toBeCalledWith(
schemaName,
tableNames,
roleName,
hasuraRoleName,
[
'select',
'insert',
Expand All @@ -59,7 +59,7 @@ describe('Provision', () => {
expect(error.message).toBe('Failed to provision endpoint: Failed to run migrations: some http error');
expect(VError.info(error)).toEqual({
schemaName: 'name',
roleName: 'role',
hasuraRoleName: 'role',
migration: 'CREATE TABLE blocks (height numeric)',
});
}
Expand All @@ -80,7 +80,7 @@ describe('Provision', () => {
expect(error.message).toBe('Failed to provision endpoint: Failed to fetch table names: some http error');
expect(VError.info(error)).toEqual({
schemaName: 'name',
roleName: 'role',
hasuraRoleName: 'role',
migration: 'CREATE TABLE blocks (height numeric)',
});
}
Expand All @@ -103,7 +103,7 @@ describe('Provision', () => {
expect(error.message).toBe('Failed to provision endpoint: Failed to track tables: some http error');
expect(VError.info(error)).toEqual({
schemaName: 'name',
roleName: 'role',
hasuraRoleName: 'role',
migration: 'CREATE TABLE blocks (height numeric)',
});
}
Expand All @@ -127,7 +127,7 @@ describe('Provision', () => {
expect(error.message).toBe('Failed to provision endpoint: Failed to track foreign key relationships: some http error');
expect(VError.info(error)).toEqual({
schemaName: 'name',
roleName: 'role',
hasuraRoleName: 'role',
migration: 'CREATE TABLE blocks (height numeric)',
});
}
Expand All @@ -153,7 +153,7 @@ describe('Provision', () => {
expect(VError.info(error)).toEqual({
migration: 'CREATE TABLE blocks (height numeric)',
schemaName: 'name',
roleName: 'role',
hasuraRoleName: 'role',
});
}
});
Expand Down

0 comments on commit bad27cb

Please sign in to comment.