use reliable way to detect createtable statements (#19897)

* use reliable way to detect createtable statements

* PR comments

* comments
This commit is contained in:
Alan Ren
2022-06-30 18:23:12 -07:00
committed by GitHub
parent 7eed81c560
commit 9a22c429a9
8 changed files with 45 additions and 5 deletions

View File

@@ -140,6 +140,7 @@ export class MockDacFxService implements mssql.IDacFxService {
public generateDeployPlan(_: string, __: string, ___: string, ____: azdata.TaskExecutionMode): Thenable<mssql.GenerateDeployPlanResult> { return Promise.resolve(mockDacFxResult); }
public getOptionsFromProfile(_: string): Thenable<mssql.DacFxOptionsResult> { return Promise.resolve(mockDacFxOptionsResult); }
public validateStreamingJob(_: string, __: string): Thenable<mssql.ValidateStreamingJobResult> { return Promise.resolve(mockDacFxResult); }
public parseTSqlScript(_: string, __: string): Thenable<mssql.ParseTSqlScriptResult> { return Promise.resolve({ containsCreateTableStatement: true }); }
}
export function createContext(): TestContext {

View File

@@ -6,6 +6,7 @@
import * as path from 'path';
import * as os from 'os';
import * as constants from '../common/constants';
import * as templates from '../templates/templates';
import { promises as fs } from 'fs';
import should = require('should');
@@ -34,6 +35,10 @@ export async function createTestSqlProjFile(contents: string, folderPath?: strin
}
export async function createTestProject(contents: string, folderPath?: string): Promise<Project> {
const macroDict: Record<string, string> = {
'PROJECT_DSP': constants.defaultDSP
};
contents = templates.macroExpansion(contents, macroDict);
return await Project.openProject(await createTestSqlProjFile(contents, folderPath));
}