Adding External Streaming Job I/O validation (#13195)

* Added Tools Service call for ValidateStreamingJob

* Partial addition of ESJ

* adding test mocks

* Validation working

* Modifying command visibility logic to submatch ESJs in addition to files

* Changed string literal to constant, corrected attribute order

* Added tests

* correcting casing that's causing test failures on linux

* Swapping Thenable for Promise

* excluded validate from command palette
This commit is contained in:
Benjin Dubishar
2020-11-02 19:02:20 -08:00
committed by GitHub
parent ba80000e27
commit 342ff47e51
20 changed files with 198 additions and 37 deletions

View File

@@ -19,7 +19,7 @@ import { promises as fs } from 'fs';
import { PublishDatabaseDialog } from '../dialogs/publishDatabaseDialog';
import { Project, reservedProjectFolders, FileProjectEntry, SqlProjectReferenceProjectEntry, IDatabaseReferenceProjectEntry } from '../models/project';
import { SqlDatabaseProjectTreeViewProvider } from './databaseProjectTreeViewProvider';
import { FolderNode, FileNode } from '../models/tree/fileFolderTreeItem';
import { FolderNode, FileNode, ExternalStreamingJobFileNode } from '../models/tree/fileFolderTreeItem';
import { IPublishSettings, IGenerateScriptSettings } from '../models/IPublishSettings';
import { BaseProjectTreeItem } from '../models/tree/baseTreeItem';
import { ProjectRootTreeItem } from '../models/tree/projectTreeItem';
@@ -204,7 +204,7 @@ export class ProjectsController {
try {
await this.netCoreTool.runDotnetCommand(options);
return path.join(project.projectFolderPath, 'bin', 'Debug', `${project.projectFileName}.dacpac`);
return project.dacpacOutputPath;
}
catch (err) {
vscode.window.showErrorMessage(constants.projBuildFailed(utils.getErrorMessage(err)));
@@ -577,6 +577,31 @@ export class ProjectsController {
}
}
public async validateExternalStreamingJob(node: ExternalStreamingJobFileNode): Promise<mssql.ValidateStreamingJobResult> {
const project: Project = this.getProjectFromContext(node);
let dacpacPath: string = project.dacpacOutputPath;
if (!await utils.exists(dacpacPath)) {
dacpacPath = await this.buildProject(node);
}
const streamingJobDefinition: string = (await fs.readFile(node.fileSystemUri.fsPath)).toString();
const dacFxService = await this.getDaxFxService();
const result: mssql.ValidateStreamingJobResult = await dacFxService.validateStreamingJob(dacpacPath, streamingJobDefinition);
if (result.success) {
vscode.window.showInformationMessage(constants.externalStreamingJobValidationPassed);
}
else {
vscode.window.showErrorMessage(result.errorMessage);
}
return result;
}
//#region Helper methods
public getPublishDialog(project: Project): PublishDatabaseDialog {