Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4ef6ed6e
Commit
4ef6ed6e
authored
Jul 24, 2020
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add and update tests for marking files as broken symlinks
parent
ea86163b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
0 deletions
+115
-0
spec/frontend/diffs/diff_file_spec.js
spec/frontend/diffs/diff_file_spec.js
+60
-0
spec/frontend/diffs/store/utils_spec.js
spec/frontend/diffs/store/utils_spec.js
+55
-0
No files found.
spec/frontend/diffs/diff_file_spec.js
0 → 100644
View file @
4ef6ed6e
import
{
prepareRawDiffFile
}
from
'
~/diffs/diff_file
'
;
const
DIFF_FILES
=
[
{
file_hash
:
'
ABC
'
,
// This file is just a normal file
},
{
file_hash
:
'
DEF
'
,
// This file replaces a symlink
a_mode
:
'
0
'
,
b_mode
:
'
0755
'
,
},
{
file_hash
:
'
DEF
'
,
// This symlink is replaced by a file
a_mode
:
'
120000
'
,
b_mode
:
'
0
'
,
},
{
file_hash
:
'
GHI
'
,
// This symlink replaces a file
a_mode
:
'
0
'
,
b_mode
:
'
120000
'
,
},
{
file_hash
:
'
GHI
'
,
// This file is replaced by a symlink
a_mode
:
'
0755
'
,
b_mode
:
'
0
'
,
},
];
function
makeBrokenSymlinkObject
(
replaced
,
wasSymbolic
,
isSymbolic
,
wasReal
,
isReal
)
{
return
{
replaced
,
wasSymbolic
,
isSymbolic
,
wasReal
,
isReal
,
};
}
describe
(
'
diff_file utilities
'
,
()
=>
{
describe
(
'
prepareRawDiffFile
'
,
()
=>
{
it
.
each
`
fileIndex | description | brokenSymlink
${
0
}
|
${
'
a file that is not symlink-adjacent
'
}
|
${
false
}
${
1
}
|
${
'
a file that replaces a symlink
'
}
|
${
makeBrokenSymlinkObject
(
false
,
false
,
false
,
false
,
true
)}
${
2
}
|
${
'
a symlink that is replaced by a file
'
}
|
${
makeBrokenSymlinkObject
(
true
,
true
,
false
,
false
,
false
)}
${
3
}
|
${
'
a symlink that replaces a file
'
}
|
${
makeBrokenSymlinkObject
(
false
,
false
,
true
,
false
,
false
)}
${
4
}
|
${
'
a file that is replaced by a symlink
'
}
|
${
makeBrokenSymlinkObject
(
true
,
false
,
false
,
true
,
false
)}
`
(
'
properly marks $description with the correct .brokenSymlink value
'
,
({
fileIndex
,
brokenSymlink
})
=>
{
const
preppedRaw
=
prepareRawDiffFile
({
file
:
DIFF_FILES
[
fileIndex
],
allFiles
:
DIFF_FILES
,
});
expect
(
preppedRaw
.
brokenSymlink
).
toStrictEqual
(
brokenSymlink
);
},
);
});
});
spec/frontend/diffs/store/utils_spec.js
View file @
4ef6ed6e
...
...
@@ -20,6 +20,14 @@ import { noteableDataMock } from '../../notes/mock_data';
const
getDiffFileMock
=
()
=>
JSON
.
parse
(
JSON
.
stringify
(
diffFileMockData
));
const
getDiffMetadataMock
=
()
=>
JSON
.
parse
(
JSON
.
stringify
(
diffMetadata
));
function
extractLinesFromFile
(
file
)
{
const
unpackedParallel
=
file
.
parallel_diff_lines
.
flatMap
(({
left
,
right
})
=>
[
left
,
right
])
.
filter
(
Boolean
);
return
[...
file
.
highlighted_diff_lines
,
...
unpackedParallel
];
}
describe
(
'
DiffsStoreUtils
'
,
()
=>
{
describe
(
'
findDiffFile
'
,
()
=>
{
const
files
=
[{
file_hash
:
1
,
name
:
'
one
'
}];
...
...
@@ -429,6 +437,28 @@ describe('DiffsStoreUtils', () => {
expect
(
preppedLine
.
right
).
toEqual
(
correctLine
);
expect
(
preppedLine
.
line_code
).
toEqual
(
correctLine
.
line_code
);
});
it
.
each
`
brokenSymlink
${
false
}
${{}}
$
{
'
anything except `false`
'
}
`
(
"
properly assigns each line's `commentsDisabled` as the same value as the parent file's `brokenSymlink` value (`$brokenSymlink`)
"
,
({
brokenSymlink
})
=>
{
preppedLine
=
utils
.
prepareLineForRenamedFile
({
diffViewType
:
INLINE_DIFF_VIEW_TYPE
,
line
:
sourceLine
,
index
:
lineIndex
,
diffFile
:
{
...
diffFile
,
brokenSymlink
,
},
});
expect
(
preppedLine
.
commentsDisabled
).
toStrictEqual
(
brokenSymlink
);
},
);
});
describe
(
'
prepareDiffData
'
,
()
=>
{
...
...
@@ -541,6 +571,25 @@ describe('DiffsStoreUtils', () => {
}),
]);
});
it
(
'
adds the `.brokenSymlink` property to each diff file
'
,
()
=>
{
preparedDiff
.
diff_files
.
forEach
(
file
=>
{
expect
(
file
).
toEqual
(
expect
.
objectContaining
({
brokenSymlink
:
false
}));
});
});
it
(
"
copies the diff file's `.brokenSymlink` value to each of that file's child lines
"
,
()
=>
{
const
lines
=
[
...
preparedDiff
.
diff_files
,
...
splitInlineDiff
.
diff_files
,
...
splitParallelDiff
.
diff_files
,
...
completedDiff
.
diff_files
,
].
flatMap
(
file
=>
extractLinesFromFile
(
file
));
lines
.
forEach
(
line
=>
{
expect
(
line
.
commentsDisabled
).
toBe
(
false
);
});
});
});
describe
(
'
for diff metadata
'
,
()
=>
{
...
...
@@ -603,6 +652,12 @@ describe('DiffsStoreUtils', () => {
},
]);
});
it
(
'
adds the `.brokenSymlink` property to each meta diff file
'
,
()
=>
{
preparedDiffFiles
.
forEach
(
file
=>
{
expect
(
file
).
toMatchObject
({
brokenSymlink
:
false
});
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment