Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("run", async () => {
const credentials = dfapi.credentials.read("redshift", "df/test_credentials/redshift.json");
const compiledGraph = await dfapi.compile({
projectDir: "df/tests/integration/redshift_project"
});
expect(compiledGraph.graphErrors.compilationErrors).to.eql([]);
expect(compiledGraph.graphErrors.validationErrors).to.eql([]);
const dbadapter = dbadapters.create(credentials, "redshift");
const adapter = adapters.create(compiledGraph.projectConfig);
// Redshift transactions are giving us headaches here. Drop tables sequentially.
const dropFunctions = [].concat(
compiledGraph.tables.map(table => () =>
dbadapter.execute(adapter.dropIfExists(table.target, adapter.baseTableType(table.type)))
),
compiledGraph.assertions.map(assertion => () =>
dbadapter.execute(adapter.dropIfExists(assertion.target, "view"))
)
);
await dropFunctions.reduce((promiseChain, fn) => promiseChain.then(fn), Promise.resolve());
// Run the tests.
const testResults = await dfapi.test(credentials, "redshift", compiledGraph.tests);
expect(testResults).to.eql([
{ name: "successful", successful: true },
it("run", async () => {
const credentials = dfapi.credentials.read(
"sqldatawarehouse",
"df/test_credentials/sqldatawarehouse.json"
);
const compiledGraph = await dfapi.compile({
projectDir: "df/tests/integration/sqldatawarehouse_project"
});
expect(compiledGraph.graphErrors.compilationErrors).to.eql([]);
expect(compiledGraph.graphErrors.validationErrors).to.eql([]);
const dbadapter = dbadapters.create(credentials, "sqldatawarehouse");
const adapter = adapters.create(compiledGraph.projectConfig);
// Drop all the tables before we do anything.
await dropAllTables(compiledGraph, adapter, dbadapter);
// Run the tests.
const testResults = await dfapi.test(credentials, "sqldatawarehouse", compiledGraph.tests);
expect(testResults).to.eql([
{ name: "successful", successful: true },
{
name: "expected more rows than got",
successful: false,
messages: ["Expected 3 rows, but saw 2 rows."]
},
{
name: "expected fewer columns than got",
successful: false,
it("run", async () => {
const compiledGraph = await dfapi.compile({
projectDir: "df/tests/integration/snowflake_project"
});
expect(compiledGraph.graphErrors.compilationErrors).to.eql([]);
expect(compiledGraph.graphErrors.validationErrors).to.eql([]);
const adapter = adapters.create(compiledGraph.projectConfig, compiledGraph.dataformCoreVersion);
// Drop all the tables before we do anything.
await dropAllTables(compiledGraph, adapter, dbadapter);
// Run the tests.
const testResults = await dfapi.test(credentials, "snowflake", compiledGraph.tests);
expect(testResults).to.eql([
{ name: "successful", successful: true },
{
name: "expected more rows than got",
successful: false,
messages: ["Expected 3 rows, but saw 2 rows."]
},
{
name: "expected fewer columns than got",
successful: false,
it("run", async () => {
const compiledGraph = await dfapi.compile({
projectDir: "df/tests/integration/bigquery_project"
});
expect(compiledGraph.graphErrors.compilationErrors).to.eql([]);
expect(compiledGraph.graphErrors.validationErrors).to.eql([]);
const adapter = adapters.create(compiledGraph.projectConfig, compiledGraph.dataformCoreVersion);
// Drop all the tables before we do anything.
await dropAllTables(compiledGraph, adapter, dbadapter);
// Run the tests.
const testResults = await dfapi.test(credentials, "bigquery", compiledGraph.tests);
expect(testResults).to.eql([
{ name: "successful", successful: true },
{
name: "expected more rows than got",
successful: false,
messages: ["Expected 3 rows, but saw 2 rows."]
},
{
name: "expected fewer columns than got",
successful: false,
export function getTestConfig(warehouse: string): ITestConfig {
const profilePath = `df/test_profiles/${warehouse}.json`;
const profile = fs.existsSync(profilePath)
? JSON.parse(fs.readFileSync(profilePath, "utf8"))
: null;
const projectDir = `df/examples/${warehouse}`;
const projectConf = JSON.parse(fs.readFileSync(path.join(projectDir, "./dataform.json"), "utf8"));
const adapter = create({ ...projectConf, gcloudProjectId: null });
return {
warehouse,
profile,
projectDir,
projectConf,
defaultSchema: projectConf.defaultSchema,
assertionSchema: projectConf.assertionSchema,
adapter
};
}
public adapter(): adapters.IAdapter {
return adapters.create(this.config);
}
public adapter(): adapters.IAdapter {
return adapters.create(this.config, dataformCoreVersion);
}