mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
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:
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user