Open sql projects in opened folder (#11333)

* open projects in workspace automatically

* add test

* fix for windows
This commit is contained in:
Kim Santiago
2020-07-14 16:20:37 -07:00
committed by GitHub
parent 24f6cd2e5b
commit de69e73a9d
4 changed files with 166 additions and 1 deletions

View File

@@ -14,7 +14,7 @@ import * as constants from '../common/constants';
import { createContext, TestContext } from './testContext';
import MainController from '../controllers/mainController';
import { shouldThrowSpecificError } from './testUtils';
import { shouldThrowSpecificError, generateTestFolderPath, createTestProject } from './testUtils';
let testContext: TestContext;
@@ -77,4 +77,27 @@ describe('MainController: main controller operations', function (): void {
should.doesNotThrow(() => controller.activate(), 'activate() should not throw an error');
should.doesNotThrow(() => controller.dispose(), 'dispose() should not throw an error');
});
it('Should load projects in workspace', async function (): Promise<void> {
const rootFolderPath = await generateTestFolderPath();
const project = await createTestProject(baselines.openProjectFileBaseline, rootFolderPath);
const nestedFolder = path.join(rootFolderPath, 'nestedProject');
const nestedProject = await createTestProject(baselines.openProjectFileBaseline, nestedFolder);
testContext.apiWrapper.setup(x => x.workspaceFolders()).returns(() => [workspaceFolder]);
const workspaceFolder: vscode.WorkspaceFolder = {
uri: vscode.Uri.file(rootFolderPath),
name: '',
index: 0
};
const controller = new MainController(testContext.context, testContext.apiWrapper.object);
should(controller.projController.projects.length).equal(0);
await controller.loadProjectsInWorkspace();
should(controller.projController.projects.length).equal(2);
should(controller.projController.projects[0].projectFolderPath).equal(project.projectFolderPath);
should(controller.projController.projects[1].projectFolderPath).equal(nestedProject.projectFolderPath);
});
});