Skip to content

Instantly share code, notes, and snippets.

@michan85
michan85 / sequelizeTest.js
Last active April 8, 2024 03:38
Automatic Transaction rollback for unit testing sequelize using jest
jest.mock("sequelize", () => {
const s = jest.requireActual("sequelize")
const cls = require('cls-hooked');
const namespace = cls.createNamespace('unit-test');
s.useCLS(namespace);
return s
})
@michan85
michan85 / dataflow_directrunner_bigquery_eu.py
Created September 11, 2018 09:25
a hack to allow setting the default location of bigquery query, for direct runner
class BigQueryReader(beam.io.gcp.bigquery.BigQueryReader):
def __init__(self, source, test_bigquery_client=None, use_legacy_sql=True,
flatten_results=True):
super(BigQueryReader,self).__init__(source, test_bigquery_client=test_bigquery_client, use_legacy_sql=use_legacy_sql,
flatten_results=flatten_results)
def _get_source_table_location(self):
loc = super(BigQueryReader, self)._get_source_table_location()