提交 d8807440 编写于 作者: R Rob Lourens

Add test for #69972

上级 7333aa8a
......@@ -5,6 +5,7 @@
import * as assert from 'assert';
import * as platform from 'vs/base/common/platform';
import * as crypto from 'crypto';
import * as os from 'os';
import * as fs from 'fs';
import * as path from 'vs/base/common/path';
......@@ -83,6 +84,31 @@ suite('BackupFileService', () => {
return pfs.del(backupHome, os.tmpdir());
});
suite('hashPath', () => {
test('should correctly hash the path for untitled scheme URIs', () => {
const uri = Uri.from({
scheme: 'untitled',
path: 'Untitled-1'
});
const actual = hashPath(uri);
// If these hashes change people will lose their backed up files!
assert.equal(actual, '13264068d108c6901b3592ea654fcd57');
assert.equal(actual, crypto.createHash('md5').update(uri.fsPath).digest('hex'));
});
test('should correctly hash the path for file scheme URIs', () => {
const uri = Uri.file('/foo');
const actual = hashPath(uri);
// If these hashes change people will lose their backed up files!
if (platform.isWindows) {
assert.equal(actual, 'dec1a583f52468a020bd120c3f01d812');
} else {
assert.equal(actual, '1effb2475fcfba4f9e8b8a1dbc8f3caf');
}
assert.equal(actual, crypto.createHash('md5').update(uri.fsPath).digest('hex'));
});
});
suite('getBackupResource', () => {
test('should get the correct backup path for text files', () => {
// Format should be: <backupHome>/<workspaceHash>/<scheme>/<filePathHash>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册