Skip to content

Commit

Permalink
Clean up testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
darunrs committed Nov 18, 2023
1 parent 9b1c397 commit a9d42a8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion runner/src/dml-handler/dml-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default class DmlHandler {
hasuraClient: HasuraClient = new HasuraClient(),
PgClient = PgClientModule
): Promise<DmlHandler> {
console.log('CALL MADE');
const connectionParameters = await hasuraClient.getDbConnectionParameters(account);
const pgClient = new PgClient({
user: connectionParameters.username,
Expand Down
4 changes: 2 additions & 2 deletions runner/src/indexer/indexer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ CREATE TABLE
expect(result.length).toEqual(2);
});

test('indexer builds context and does simultaneous inserts', async () => {
test('indexer builds context and does simultaneous upserts', async () => {
const mockDmlHandler: any = {
create: jest.fn().mockImplementation(() => {
return { upsert: jest.fn().mockReturnValue([{ colA: 'valA' }, { colA: 'valA' }]) };
Expand Down Expand Up @@ -500,7 +500,7 @@ CREATE TABLE
}
await Promise.all(promises);
expect(mockDmlHandler.create).toHaveBeenCalledTimes(1);
}, 100000);
});

test('indexer builds context and selects objects from existing table', async () => {
const selectFn = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion runner/src/indexer/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export default class Indexer {

return {
...prev,
...funcForTable,
...funcForTable
};
}, {});
return result;
Expand Down
4 changes: 2 additions & 2 deletions runner/src/pg-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ interface ConnectionParams {
export default class PgClient {
private readonly pgPool: Pool;
public format: typeof pgFormatModule;
sleep = async (ms: number): Promise<void> => { await new Promise((resolve) => setTimeout(resolve, ms)); };

constructor (
connectionParams: ConnectionParams,
poolConfig: PoolConfig = { max: 2, idleTimeoutMillis: 30000 },
poolConfig: PoolConfig = { max: 10, idleTimeoutMillis: 30000 },
PgPool: typeof Pool = Pool,
pgFormat: typeof pgFormatModule = pgFormatModule
) {
Expand All @@ -32,6 +31,7 @@ export default class PgClient {
}

async query<R extends QueryResultRow = any>(query: string, params: any[] = []): Promise<QueryResult<R>> {
// Automatically manages client connections to pool
return await this.pgPool.query<R>(query, params);
}
}

0 comments on commit a9d42a8

Please sign in to comment.