Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d26e39b3
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d26e39b3
编写于
9月 16, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
💄
tests
上级
4ace80eb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
23 deletion
+23
-23
src/vs/platform/backup/test/electron-main/backupMainService.test.ts
...tform/backup/test/electron-main/backupMainService.test.ts
+23
-23
未找到文件。
src/vs/platform/backup/test/electron-main/backupMainService.test.ts
浏览文件 @
d26e39b3
...
...
@@ -9,7 +9,7 @@ import * as fs from 'fs';
import
*
as
os
from
'
os
'
;
import
*
as
path
from
'
vs/base/common/path
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
URI
as
Uri
,
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
parseArgs
,
OPTIONS
}
from
'
vs/platform/environment/node/argv
'
;
import
{
BackupMainService
}
from
'
vs/platform/backup/electron-main/backupMainService
'
;
...
...
@@ -24,7 +24,7 @@ import { Schemas } from 'vs/base/common/network';
suite
(
'
BackupMainService
'
,
()
=>
{
function
assertEqualUris
(
actual
:
U
ri
[],
expected
:
Uri
[])
{
function
assertEqualUris
(
actual
:
U
RI
[],
expected
:
URI
[])
{
assert
.
deepEqual
(
actual
.
map
(
a
=>
a
.
toString
()),
expected
.
map
(
a
=>
a
.
toString
()));
}
...
...
@@ -43,12 +43,12 @@ suite('BackupMainService', () => {
this
.
workspacesJsonPath
=
backupWorkspacesPath
;
}
public
toBackupPath
(
arg
:
U
ri
|
string
):
string
{
const
id
=
arg
instanceof
U
ri
?
super
.
getFolderHash
(
arg
)
:
arg
;
public
toBackupPath
(
arg
:
U
RI
|
string
):
string
{
const
id
=
arg
instanceof
U
RI
?
super
.
getFolderHash
(
arg
)
:
arg
;
return
path
.
join
(
this
.
backupHome
,
id
);
}
public
getFolderHash
(
folderUri
:
U
ri
):
string
{
public
getFolderHash
(
folderUri
:
U
RI
):
string
{
return
super
.
getFolderHash
(
folderUri
);
}
...
...
@@ -81,7 +81,7 @@ suite('BackupMainService', () => {
};
}
async
function
ensureFolderExists
(
uri
:
U
ri
):
Promise
<
void
>
{
async
function
ensureFolderExists
(
uri
:
U
RI
):
Promise
<
void
>
{
if
(
!
fs
.
existsSync
(
uri
.
fsPath
))
{
fs
.
mkdirSync
(
uri
.
fsPath
);
}
...
...
@@ -110,10 +110,10 @@ suite('BackupMainService', () => {
return
platform
.
isLinux
?
p
:
p
.
toLowerCase
();
}
const
fooFile
=
U
ri
.
file
(
platform
.
isWindows
?
'
C:
\\
foo
'
:
'
/foo
'
);
const
barFile
=
U
ri
.
file
(
platform
.
isWindows
?
'
C:
\\
bar
'
:
'
/bar
'
);
const
fooFile
=
U
RI
.
file
(
platform
.
isWindows
?
'
C:
\\
foo
'
:
'
/foo
'
);
const
barFile
=
U
RI
.
file
(
platform
.
isWindows
?
'
C:
\\
bar
'
:
'
/bar
'
);
const
existingTestFolder1
=
U
ri
.
file
(
path
.
join
(
parentDir
,
'
folder1
'
));
const
existingTestFolder1
=
U
RI
.
file
(
path
.
join
(
parentDir
,
'
folder1
'
));
let
service
:
TestBackupMainService
;
let
configService
:
TestConfigurationService
;
...
...
@@ -231,7 +231,7 @@ suite('BackupMainService', () => {
const
backupPathToMigrate
=
service
.
toBackupPath
(
fooFile
);
fs
.
mkdirSync
(
backupPathToMigrate
);
fs
.
writeFileSync
(
path
.
join
(
backupPathToMigrate
,
'
backup.txt
'
),
'
Some Data
'
);
service
.
registerFolderBackupSync
(
U
ri
.
file
(
backupPathToMigrate
));
service
.
registerFolderBackupSync
(
U
RI
.
file
(
backupPathToMigrate
));
const
workspaceBackupPath
=
service
.
registerWorkspaceBackupSync
(
toWorkspaceBackupInfo
(
barFile
.
fsPath
),
backupPathToMigrate
);
...
...
@@ -247,12 +247,12 @@ suite('BackupMainService', () => {
const
backupPathToMigrate
=
service
.
toBackupPath
(
fooFile
);
fs
.
mkdirSync
(
backupPathToMigrate
);
fs
.
writeFileSync
(
path
.
join
(
backupPathToMigrate
,
'
backup.txt
'
),
'
Some Data
'
);
service
.
registerFolderBackupSync
(
U
ri
.
file
(
backupPathToMigrate
));
service
.
registerFolderBackupSync
(
U
RI
.
file
(
backupPathToMigrate
));
const
backupPathToPreserve
=
service
.
toBackupPath
(
barFile
);
fs
.
mkdirSync
(
backupPathToPreserve
);
fs
.
writeFileSync
(
path
.
join
(
backupPathToPreserve
,
'
backup.txt
'
),
'
Some Data
'
);
service
.
registerFolderBackupSync
(
U
ri
.
file
(
backupPathToPreserve
));
service
.
registerFolderBackupSync
(
U
RI
.
file
(
backupPathToPreserve
));
const
workspaceBackupPath
=
service
.
registerWorkspaceBackupSync
(
toWorkspaceBackupInfo
(
barFile
.
fsPath
),
backupPathToMigrate
);
...
...
@@ -270,8 +270,8 @@ suite('BackupMainService', () => {
test
(
'
migration folder path to URI makes sure to preserve existing backups
'
,
async
()
=>
{
let
path1
=
path
.
join
(
parentDir
,
'
folder1
'
);
let
path2
=
path
.
join
(
parentDir
,
'
FOLDER2
'
);
let
uri1
=
U
ri
.
file
(
path1
);
let
uri2
=
U
ri
.
file
(
path2
);
let
uri1
=
U
RI
.
file
(
path1
);
let
uri2
=
U
RI
.
file
(
path2
);
if
(
!
fs
.
existsSync
(
path1
))
{
fs
.
mkdirSync
(
path1
);
...
...
@@ -372,8 +372,8 @@ suite('BackupMainService', () => {
});
test
(
'
getFolderBackupPaths() should return [] when files.hotExit = "onExitAndWindowClose"
'
,
async
()
=>
{
service
.
registerFolderBackupSync
(
U
ri
.
file
(
fooFile
.
fsPath
.
toUpperCase
()));
assertEqualUris
(
service
.
getFolderBackupPaths
(),
[
U
ri
.
file
(
fooFile
.
fsPath
.
toUpperCase
())]);
service
.
registerFolderBackupSync
(
U
RI
.
file
(
fooFile
.
fsPath
.
toUpperCase
()));
assertEqualUris
(
service
.
getFolderBackupPaths
(),
[
U
RI
.
file
(
fooFile
.
fsPath
.
toUpperCase
())]);
configService
.
setUserConfiguration
(
'
files.hotExit
'
,
HotExitConfiguration
.
ON_EXIT_AND_WINDOW_CLOSE
);
await
service
.
initialize
();
assertEqualUris
(
service
.
getFolderBackupPaths
(),
[]);
...
...
@@ -591,11 +591,11 @@ suite('BackupMainService', () => {
});
test
(
'
should always store the workspace path in workspaces.json using the case given, regardless of whether the file system is case-sensitive (folder workspace)
'
,
()
=>
{
service
.
registerFolderBackupSync
(
U
ri
.
file
(
fooFile
.
fsPath
.
toUpperCase
()));
assertEqualUris
(
service
.
getFolderBackupPaths
(),
[
U
ri
.
file
(
fooFile
.
fsPath
.
toUpperCase
())]);
service
.
registerFolderBackupSync
(
U
RI
.
file
(
fooFile
.
fsPath
.
toUpperCase
()));
assertEqualUris
(
service
.
getFolderBackupPaths
(),
[
U
RI
.
file
(
fooFile
.
fsPath
.
toUpperCase
())]);
return
pfs
.
readFile
(
backupWorkspacesPath
,
'
utf-8
'
).
then
(
buffer
=>
{
const
json
=
<
IBackupWorkspacesFormat
>
JSON
.
parse
(
buffer
);
assert
.
deepEqual
(
json
.
folderURIWorkspaces
,
[
U
ri
.
file
(
fooFile
.
fsPath
.
toUpperCase
()).
toString
()]);
assert
.
deepEqual
(
json
.
folderURIWorkspaces
,
[
U
RI
.
file
(
fooFile
.
fsPath
.
toUpperCase
()).
toString
()]);
});
});
...
...
@@ -681,11 +681,11 @@ suite('BackupMainService', () => {
}
if
(
platform
.
isMacintosh
)
{
assert
.
equal
(
service
.
getFolderHash
(
U
ri
.
file
(
'
/foo
'
)),
service
.
getFolderHash
(
Uri
.
file
(
'
/FOO
'
)));
assert
.
equal
(
service
.
getFolderHash
(
U
RI
.
file
(
'
/foo
'
)),
service
.
getFolderHash
(
URI
.
file
(
'
/FOO
'
)));
}
if
(
platform
.
isWindows
)
{
assert
.
equal
(
service
.
getFolderHash
(
U
ri
.
file
(
'
c:
\\
foo
'
)),
service
.
getFolderHash
(
Uri
.
file
(
'
C:
\\
FOO
'
)));
assert
.
equal
(
service
.
getFolderHash
(
U
RI
.
file
(
'
c:
\\
foo
'
)),
service
.
getFolderHash
(
URI
.
file
(
'
C:
\\
FOO
'
)));
}
});
});
...
...
@@ -693,7 +693,7 @@ suite('BackupMainService', () => {
suite
(
'
mixed path casing
'
,
()
=>
{
test
(
'
should handle case insensitive paths properly (registerWindowForBackupsSync) (folder workspace)
'
,
()
=>
{
service
.
registerFolderBackupSync
(
fooFile
);
service
.
registerFolderBackupSync
(
U
ri
.
file
(
fooFile
.
fsPath
.
toUpperCase
()));
service
.
registerFolderBackupSync
(
U
RI
.
file
(
fooFile
.
fsPath
.
toUpperCase
()));
if
(
platform
.
isLinux
)
{
assert
.
equal
(
service
.
getFolderBackupPaths
().
length
,
2
);
...
...
@@ -722,7 +722,7 @@ suite('BackupMainService', () => {
// mixed case
service
.
registerFolderBackupSync
(
fooFile
);
service
.
unregisterFolderBackupSync
(
U
ri
.
file
(
fooFile
.
fsPath
.
toUpperCase
()));
service
.
unregisterFolderBackupSync
(
U
RI
.
file
(
fooFile
.
fsPath
.
toUpperCase
()));
if
(
platform
.
isLinux
)
{
assert
.
equal
(
service
.
getFolderBackupPaths
().
length
,
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录