Feature/outer paths for project (#11445)

* allow relative paths in project file outside of project folder

* Adding some tests

* Adding error string to loc strings

* Fixed test

* fix error message

* PR comments and some more fixes
This commit is contained in:
Udeesha Gautam
2020-07-22 19:28:03 -07:00
committed by GitHub
parent efc8182954
commit 196b3752a9
13 changed files with 112 additions and 36 deletions

View File

@@ -5,10 +5,12 @@
import * as should from 'should';
import * as path from 'path';
import {createDummyFileStructure} from './testUtils';
import { exists} from '../common/utils';
import * as os from 'os';
import { createDummyFileStructure } from './testUtils';
import { exists, trimUri } from '../common/utils';
import { Uri } from 'vscode';
describe('Tests to verify exists function', function (): void {
describe('Tests to verify utils functions', function (): void {
it('Should determine existence of files/folders', async () => {
let testFolderPath = await createDummyFileStructure();
@@ -16,8 +18,25 @@ describe('Tests to verify exists function', function (): void {
should(await exists(path.join(testFolderPath, 'file1.sql'))).equal(true);
should(await exists(path.join(testFolderPath, 'folder2'))).equal(true);
should(await exists(path.join(testFolderPath, 'folder4'))).equal(false);
should(await exists(path.join(testFolderPath, 'folder2','file4.sql'))).equal(true);
should(await exists(path.join(testFolderPath, 'folder4','file2.sql'))).equal(false);
should(await exists(path.join(testFolderPath, 'folder2', 'file4.sql'))).equal(true);
should(await exists(path.join(testFolderPath, 'folder4', 'file2.sql'))).equal(false);
});
it('Should get correct relative paths of files/folders', async () => {
const root = os.platform() === 'win32' ? 'Z:\\' : '/';
let projectUri = Uri.file(path.join(root, 'project', 'folder', 'project.sqlproj'));
let fileUri = Uri.file(path.join(root, 'project', 'folder', 'file.sql'));
should(trimUri(projectUri, fileUri)).equal('file.sql');
fileUri = Uri.file(path.join(root, 'project', 'file.sql'));
let urifile = trimUri(projectUri, fileUri);
should(urifile).equal('../file.sql');
fileUri = Uri.file(path.join(root, 'project', 'forked', 'file.sql'));
should(trimUri(projectUri, fileUri)).equal('../forked/file.sql');
fileUri = Uri.file(path.join(root, 'forked', 'from', 'top', 'file.sql'));
should(trimUri(projectUri, fileUri)).equal('../../forked/from/top/file.sql');
});
});