Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3ac4b025
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,发现更多精彩内容 >>
提交
3ac4b025
编写于
1月 21, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tests
上级
439e6181
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
78 addition
and
110 deletion
+78
-110
src/vs/platform/userDataSync/test/common/settingsMerge.test.ts
...s/platform/userDataSync/test/common/settingsMerge.test.ts
+78
-110
未找到文件。
src/vs/platform/userDataSync/test/common/settingsMerge.test.ts
浏览文件 @
3ac4b025
...
@@ -5,10 +5,11 @@
...
@@ -5,10 +5,11 @@
import
*
as
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
merge
,
updateIgnoredSettings
,
addSetting
}
from
'
vs/platform/userDataSync/common/settingsMerge
'
;
import
{
merge
,
updateIgnoredSettings
,
addSetting
}
from
'
vs/platform/userDataSync/common/settingsMerge
'
;
import
type
{
IConflictSetting
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
const
formattingOptions
=
{
eol
:
'
\n
'
,
insertSpaces
:
false
,
tabSize
:
4
};
const
formattingOptions
=
{
eol
:
'
\n
'
,
insertSpaces
:
false
,
tabSize
:
4
};
suite
(
'
SettingsMerge -
No Conflicts
'
,
()
=>
{
suite
(
'
SettingsMerge -
Merge
'
,
()
=>
{
test
(
'
merge when local and remote are same with one entry
'
,
async
()
=>
{
test
(
'
merge when local and remote are same with one entry
'
,
async
()
=>
{
const
localContent
=
stringify
({
'
a
'
:
1
});
const
localContent
=
stringify
({
'
a
'
:
1
});
...
@@ -262,11 +263,6 @@ suite('SettingsMerge - No Conflicts', () => {
...
@@ -262,11 +263,6 @@ suite('SettingsMerge - No Conflicts', () => {
assert
.
ok
(
!
actual
.
hasConflicts
);
assert
.
ok
(
!
actual
.
hasConflicts
);
});
});
});
/*
suite('SettingsMerge - Conflicts', () => {
test
(
'
merge when local and remote with one entry but different value
'
,
async
()
=>
{
test
(
'
merge when local and remote with one entry but different value
'
,
async
()
=>
{
const
localContent
=
stringify
({
const
localContent
=
stringify
({
'
a
'
:
1
'
a
'
:
1
...
@@ -276,16 +272,10 @@ suite('SettingsMerge - Conflicts', () => {
...
@@ -276,16 +272,10 @@ suite('SettingsMerge - Conflicts', () => {
});
});
const
expectedConflicts
:
IConflictSetting
[]
=
[{
key
:
'
a
'
,
localValue
:
1
,
remoteValue
:
2
}];
const
expectedConflicts
:
IConflictSetting
[]
=
[{
key
:
'
a
'
,
localValue
:
1
,
remoteValue
:
2
}];
const
actual
=
merge
(
localContent
,
remoteContent
,
null
,
[],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
null
,
[],
[],
formattingOptions
);
assert.ok(actual.hasChanges);
assert
.
equal
(
actual
.
localContent
,
localContent
);
assert.deepEqual(actual.conflicts, expectedConflicts);
assert
.
equal
(
actual
.
remoteContent
,
remoteContent
);
assert.equal(actual.mergeContent,
assert
.
ok
(
actual
.
hasConflicts
);
`{
assert
.
deepEqual
(
actual
.
conflictsSettings
,
expectedConflicts
);
<<<<<<< local
"a": 1
=======
"a": 2,
>>>>>>> remote
}`);
});
});
test
(
'
merge when the entry is removed in remote but updated in local and a new entry is added in remote
'
,
async
()
=>
{
test
(
'
merge when the entry is removed in remote but updated in local and a new entry is added in remote
'
,
async
()
=>
{
...
@@ -300,16 +290,13 @@ suite('SettingsMerge - Conflicts', () => {
...
@@ -300,16 +290,13 @@ suite('SettingsMerge - Conflicts', () => {
});
});
const
expectedConflicts
:
IConflictSetting
[]
=
[{
key
:
'
a
'
,
localValue
:
2
,
remoteValue
:
undefined
}];
const
expectedConflicts
:
IConflictSetting
[]
=
[{
key
:
'
a
'
,
localValue
:
2
,
remoteValue
:
undefined
}];
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[],
[],
formattingOptions
);
assert.ok(actual.hasChanges);
assert
.
equal
(
actual
.
localContent
,
stringify
({
assert.deepEqual(actual.conflicts, expectedConflicts);
'
a
'
:
2
,
assert.equal(actual.mergeContent,
'
b
'
:
2
`{
}));
<<<<<<< local
assert
.
equal
(
actual
.
remoteContent
,
remoteContent
);
"a": 2,
assert
.
ok
(
actual
.
hasConflicts
);
=======
assert
.
deepEqual
(
actual
.
conflictsSettings
,
expectedConflicts
);
>>>>>>> remote
"b": 2
}`);
});
});
test
(
'
merge with single entry and local is empty
'
,
async
()
=>
{
test
(
'
merge with single entry and local is empty
'
,
async
()
=>
{
...
@@ -322,15 +309,10 @@ suite('SettingsMerge - Conflicts', () => {
...
@@ -322,15 +309,10 @@ suite('SettingsMerge - Conflicts', () => {
});
});
const
expectedConflicts
:
IConflictSetting
[]
=
[{
key
:
'
a
'
,
localValue
:
undefined
,
remoteValue
:
2
}];
const
expectedConflicts
:
IConflictSetting
[]
=
[{
key
:
'
a
'
,
localValue
:
undefined
,
remoteValue
:
2
}];
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[],
[],
formattingOptions
);
assert.ok(actual.hasChanges);
assert
.
equal
(
actual
.
localContent
,
localContent
);
assert.deepEqual(actual.conflicts, expectedConflicts);
assert
.
equal
(
actual
.
remoteContent
,
remoteContent
);
assert.equal(actual.mergeContent,
assert
.
ok
(
actual
.
hasConflicts
);
`{
assert
.
deepEqual
(
actual
.
conflictsSettings
,
expectedConflicts
);
<<<<<<< local
=======
"a": 2,
>>>>>>> remote
}`);
});
});
test
(
'
merge when local and remote has moved forwareded with conflicts
'
,
async
()
=>
{
test
(
'
merge when local and remote has moved forwareded with conflicts
'
,
async
()
=>
{
...
@@ -356,38 +338,29 @@ suite('SettingsMerge - Conflicts', () => {
...
@@ -356,38 +338,29 @@ suite('SettingsMerge - Conflicts', () => {
const
expectedConflicts
:
IConflictSetting
[]
=
[
const
expectedConflicts
:
IConflictSetting
[]
=
[
{
key
:
'
b
'
,
localValue
:
undefined
,
remoteValue
:
3
},
{
key
:
'
b
'
,
localValue
:
undefined
,
remoteValue
:
3
},
{
key
:
'
a
'
,
localValue
:
2
,
remoteValue
:
undefined
},
{
key
:
'
a
'
,
localValue
:
2
,
remoteValue
:
undefined
},
{ key: 'e', localValue: 4, remoteValue: 5 },
{
key
:
'
d
'
,
localValue
:
5
,
remoteValue
:
6
},
{
key
:
'
d
'
,
localValue
:
5
,
remoteValue
:
6
},
{
key
:
'
e
'
,
localValue
:
4
,
remoteValue
:
5
},
];
];
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[],
[],
formattingOptions
);
assert.ok(actual.hasChanges);
assert
.
equal
(
actual
.
localContent
,
stringify
({
assert.deepEqual(actual.conflicts, expectedConflicts);
'
a
'
:
2
,
assert.equal(actual.mergeContent,
'
c
'
:
3
,
`{
'
d
'
:
5
,
<<<<<<< local
'
e
'
:
4
,
"a": 2,
'
f
'
:
1
,
=======
}));
>>>>>>> remote
assert
.
equal
(
actual
.
remoteContent
,
stringify
({
"c": 3,
'
b
'
:
3
,
<<<<<<< local
'
c
'
:
3
,
"d": 5,
'
d
'
:
6
,
=======
'
e
'
:
5
,
"d": 6,
'
f
'
:
1
,
>>>>>>> remote
}));
<<<<<<< local
assert
.
ok
(
actual
.
hasConflicts
);
"e": 4,
assert
.
deepEqual
(
actual
.
conflictsSettings
,
expectedConflicts
);
=======
"e": 5,
>>>>>>> remote
"f": 1
<<<<<<< local
=======
"b": 3,
>>>>>>> remote
}`);
});
});
test('resolve when local and remote has moved forwareded with conflicts', async () => {
test
(
'
resolve when local and remote has moved forwareded with
resolved
conflicts
'
,
async
()
=>
{
const
baseContent
=
stringify
({
const
baseContent
=
stringify
({
'
a
'
:
1
,
'
a
'
:
1
,
'
b
'
:
2
,
'
b
'
:
2
,
...
@@ -411,27 +384,24 @@ suite('SettingsMerge - Conflicts', () => {
...
@@ -411,27 +384,24 @@ suite('SettingsMerge - Conflicts', () => {
{
key
:
'
d
'
,
localValue
:
5
,
remoteValue
:
6
},
{
key
:
'
d
'
,
localValue
:
5
,
remoteValue
:
6
},
];
];
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[],
[{
key
:
'
a
'
,
value
:
2
},
{
key
:
'
b
'
,
value
:
undefined
},
{
key
:
'
e
'
,
value
:
5
}],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[],
[{
key
:
'
a
'
,
value
:
2
},
{
key
:
'
b
'
,
value
:
undefined
},
{
key
:
'
e
'
,
value
:
5
}],
formattingOptions
);
assert.ok(actual.hasChanges);
assert
.
equal
(
actual
.
localContent
,
stringify
({
assert.deepEqual(actual.conflicts, expectedConflicts);
'
a
'
:
2
,
assert.equal(actual.mergeContent,
'
c
'
:
3
,
`{
'
d
'
:
5
,
"a": 2,
'
e
'
:
5
,
"c": 3,
'
f
'
:
1
,
<<<<<<< local
}));
"d": 5,
assert
.
equal
(
actual
.
remoteContent
,
stringify
({
=======
'
c
'
:
3
,
"d": 6,
'
d
'
:
6
,
>>>>>>> remote
'
e
'
:
5
,
"e": 5,
'
f
'
:
1
,
"f": 1
'
a
'
:
2
,
}`);
}));
assert
.
ok
(
actual
.
hasConflicts
);
assert
.
deepEqual
(
actual
.
conflictsSettings
,
expectedConflicts
);
});
});
});
*/
suite
(
'
SettingsMerge - Ignored Settings
'
,
()
=>
{
test
(
'
ignored setting is not merged when changed in local and remote
'
,
async
()
=>
{
test
(
'
ignored setting is not merged when changed in local and remote
'
,
async
()
=>
{
const
localContent
=
stringify
({
'
a
'
:
1
});
const
localContent
=
stringify
({
'
a
'
:
1
});
const
remoteContent
=
stringify
({
'
a
'
:
2
});
const
remoteContent
=
stringify
({
'
a
'
:
2
});
...
@@ -448,7 +418,7 @@ suite('SettingsMerge - Ignored Settings', () => {
...
@@ -448,7 +418,7 @@ suite('SettingsMerge - Ignored Settings', () => {
const
remoteContent
=
stringify
({
'
a
'
:
2
});
const
remoteContent
=
stringify
({
'
a
'
:
2
});
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[
'
a
'
],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[
'
a
'
],
[],
formattingOptions
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
remoteContent
,
localContent
);
assert
.
equal
(
actual
.
remoteContent
,
null
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
ok
(
!
actual
.
hasConflicts
);
assert
.
ok
(
!
actual
.
hasConflicts
);
});
});
...
@@ -458,7 +428,7 @@ suite('SettingsMerge - Ignored Settings', () => {
...
@@ -458,7 +428,7 @@ suite('SettingsMerge - Ignored Settings', () => {
const
remoteContent
=
stringify
({
'
a
'
:
1
});
const
remoteContent
=
stringify
({
'
a
'
:
1
});
const
actual
=
merge
(
localContent
,
remoteContent
,
null
,
[
'
a
'
],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
null
,
[
'
a
'
],
[],
formattingOptions
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
remoteContent
,
localContent
);
assert
.
equal
(
actual
.
remoteContent
,
null
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
ok
(
!
actual
.
hasConflicts
);
assert
.
ok
(
!
actual
.
hasConflicts
);
});
});
...
@@ -468,7 +438,7 @@ suite('SettingsMerge - Ignored Settings', () => {
...
@@ -468,7 +438,7 @@ suite('SettingsMerge - Ignored Settings', () => {
const
remoteContent
=
stringify
({
'
a
'
:
1
,
'
b
'
:
2
});
const
remoteContent
=
stringify
({
'
a
'
:
1
,
'
b
'
:
2
});
const
actual
=
merge
(
localContent
,
remoteContent
,
localContent
,
[
'
a
'
],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
localContent
,
[
'
a
'
],
[],
formattingOptions
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
remoteContent
,
localContent
);
assert
.
equal
(
actual
.
remoteContent
,
null
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
ok
(
!
actual
.
hasConflicts
);
assert
.
ok
(
!
actual
.
hasConflicts
);
});
});
...
@@ -478,7 +448,7 @@ suite('SettingsMerge - Ignored Settings', () => {
...
@@ -478,7 +448,7 @@ suite('SettingsMerge - Ignored Settings', () => {
const
remoteContent
=
stringify
({});
const
remoteContent
=
stringify
({});
const
actual
=
merge
(
localContent
,
remoteContent
,
null
,
[
'
a
'
],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
null
,
[
'
a
'
],
[],
formattingOptions
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
remoteContent
,
localContent
);
assert
.
equal
(
actual
.
remoteContent
,
null
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
ok
(
!
actual
.
hasConflicts
);
assert
.
ok
(
!
actual
.
hasConflicts
);
});
});
...
@@ -488,7 +458,7 @@ suite('SettingsMerge - Ignored Settings', () => {
...
@@ -488,7 +458,7 @@ suite('SettingsMerge - Ignored Settings', () => {
const
remoteContent
=
stringify
({});
const
remoteContent
=
stringify
({});
const
actual
=
merge
(
localContent
,
remoteContent
,
localContent
,
[
'
a
'
],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
localContent
,
[
'
a
'
],
[],
formattingOptions
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
localContent
,
null
);
assert
.
equal
(
actual
.
remoteContent
,
localContent
);
assert
.
equal
(
actual
.
remoteContent
,
null
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
ok
(
!
actual
.
hasConflicts
);
assert
.
ok
(
!
actual
.
hasConflicts
);
});
});
...
@@ -512,18 +482,21 @@ suite('SettingsMerge - Ignored Settings', () => {
...
@@ -512,18 +482,21 @@ suite('SettingsMerge - Ignored Settings', () => {
'
d
'
:
4
,
'
d
'
:
4
,
'
e
'
:
6
,
'
e
'
:
6
,
});
});
const
expectedContent
=
stringify
({
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[
'
a
'
,
'
e
'
],
[],
formattingOptions
);
assert
.
equal
(
actual
.
localContent
,
stringify
({
'
a
'
:
1
,
'
a
'
:
1
,
'
b
'
:
3
,
'
b
'
:
3
,
});
}));
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[
'
a
'
,
'
e
'
],
[],
formattingOptions
);
assert
.
equal
(
actual
.
remoteContent
,
stringify
({
assert
.
equal
(
actual
.
localContent
,
expectedContent
);
'
a
'
:
3
,
assert
.
equal
(
actual
.
remoteContent
,
expectedContent
);
'
b
'
:
3
,
'
e
'
:
6
,
}));
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
equal
(
actual
.
conflictsSettings
.
length
,
0
);
assert
.
ok
(
!
actual
.
hasConflicts
);
assert
.
ok
(
!
actual
.
hasConflicts
);
});
});
/*
test('ignored setting is not merged with other changes conflicts', async () => {
test
(
'
ignored setting is not merged with other changes conflicts
'
,
async
()
=>
{
const
baseContent
=
stringify
({
const
baseContent
=
stringify
({
'
a
'
:
2
,
'
a
'
:
2
,
'
b
'
:
2
,
'
b
'
:
2
,
...
@@ -547,24 +520,19 @@ suite('SettingsMerge - Ignored Settings', () => {
...
@@ -547,24 +520,19 @@ suite('SettingsMerge - Ignored Settings', () => {
{
key
:
'
b
'
,
localValue
:
4
,
remoteValue
:
3
},
{
key
:
'
b
'
,
localValue
:
4
,
remoteValue
:
3
},
];
];
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[
'
a
'
,
'
e
'
],
[],
formattingOptions
);
const
actual
=
merge
(
localContent
,
remoteContent
,
baseContent
,
[
'
a
'
,
'
e
'
],
[],
formattingOptions
);
assert.ok(actual.hasChanges);
assert
.
equal
(
actual
.
localContent
,
stringify
({
assert.ok(actual.hasChanges);
'
a
'
:
1
,
assert.deepEqual(actual.conflicts, expectedConflicts);
'
b
'
:
4
,
assert.equal(actual.mergeContent,
'
d
'
:
5
,
`{
}));
"a": 1,
assert
.
equal
(
actual
.
remoteContent
,
stringify
({
<<<<<<< local
'
a
'
:
3
,
"b": 4,
'
b
'
:
3
,
=======
'
e
'
:
6
,
"b": 3,
}));
>>>>>>> remote
assert
.
deepEqual
(
actual
.
conflictsSettings
,
expectedConflicts
);
<<<<<<< local
assert
.
ok
(
actual
.
hasConflicts
);
"d": 5
});
=======
>>>>>>> remote
}`);
}); */
});
});
suite
(
'
SettingsMerge - Compute Remote Content
'
,
()
=>
{
suite
(
'
SettingsMerge - Compute Remote Content
'
,
()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录