From bad27cb0bb696681f57608c226f56815798619ea Mon Sep 17 00:00:00 2001 From: Morgan Mccauley Date: Thu, 29 Jun 2023 10:34:45 +1200 Subject: [PATCH] refactor: Rename `roleName`->`hasuraRoleName` to avoid confusion with PG role --- indexer-js-queue-handler/provisioner.js | 10 +++++----- indexer-js-queue-handler/provisioner.test.js | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/indexer-js-queue-handler/provisioner.js b/indexer-js-queue-handler/provisioner.js index 8ac1c3812..4b3eb739a 100644 --- a/indexer-js-queue-handler/provisioner.js +++ b/indexer-js-queue-handler/provisioner.js @@ -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) { @@ -58,7 +58,7 @@ export default class Provisioner { } } - async createAuthenticatedEndpoint(schemaName, roleName, migration) { + async createAuthenticatedEndpoint(schemaName, hasuraRoleName, migration) { try { await this.runMigrations(schemaName, migration); @@ -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, } }, diff --git a/indexer-js-queue-handler/provisioner.test.js b/indexer-js-queue-handler/provisioner.test.js index 237fbc400..f16e4a47c 100644 --- a/indexer-js-queue-handler/provisioner.test.js +++ b/indexer-js-queue-handler/provisioner.test.js @@ -25,9 +25,9 @@ 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); @@ -35,7 +35,7 @@ describe('Provision', () => { expect(hasuraClient.addPermissionsToTables).toBeCalledWith( schemaName, tableNames, - roleName, + hasuraRoleName, [ 'select', 'insert', @@ -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)', }); } @@ -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)', }); } @@ -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)', }); } @@ -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)', }); } @@ -153,7 +153,7 @@ describe('Provision', () => { expect(VError.info(error)).toEqual({ migration: 'CREATE TABLE blocks (height numeric)', schemaName: 'name', - roleName: 'role', + hasuraRoleName: 'role', }); } });