Skip to content

Commit 5493bfa

Browse files
committed
Update tests for -z
swap \n to \x00 and the spaces in detailed log to tabs.
1 parent 8ef8793 commit 5493bfa

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

jupyterlab_git/tests/test_detailed_log.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ async def test_detailed_log():
1717
# Given
1818
process_output = [
1919
"f29660a (HEAD, origin/feature) Commit message",
20-
"10 3 notebook_without_spaces.ipynb",
21-
"11 4 Notebook with spaces.ipynb",
22-
"12 5 path/notebook_without_spaces.ipynb",
23-
"13 6 path/Notebook with spaces.ipynb",
20+
"10\t3\tnotebook_without_spaces.ipynb",
21+
"11\t4\tNotebook with spaces.ipynb",
22+
"12\t5\tpath/notebook_without_spaces.ipynb",
23+
"13\t6\tpath/Notebook with spaces.ipynb",
2424
" notebook_without_spaces.ipynb | 13 ++++++++---",
2525
" Notebook with spaces.ipynb | 15 +++++++++----",
2626
" path/notebook_without_spaces.ipynb | 17 ++++++++++-----",
2727
" path/Notebook with spaces.ipynb | 19 +++++++++++------",
2828
" 4 files changed, 46 insertions(+), 18 deletions(-)",
2929
]
3030
mock_execute.return_value = tornado.gen.maybe_future(
31-
(0, "\n".join(process_output), "")
31+
(0, "\x00".join(process_output), "")
3232
)
3333

3434
expected_response = {
@@ -83,6 +83,7 @@ async def test_detailed_log():
8383
"--stat",
8484
"--numstat",
8585
"--oneline",
86+
"-z",
8687
"f29660a2472e24164906af8653babeb48e4bf2ab",
8788
],
8889
cwd=os.path.join("/bin", "test_curr_path"),

jupyterlab_git/tests/test_diff.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def test_changed_files_single_commit():
2424
with patch("jupyterlab_git.git.execute") as mock_execute:
2525
# Given
2626
mock_execute.return_value = tornado.gen.maybe_future(
27-
(0, "file1.ipynb\nfile2.py", "")
27+
(0, "file1.ipynb\x00file2.py", "")
2828
)
2929

3030
# When
@@ -39,6 +39,7 @@ async def test_changed_files_single_commit():
3939
"diff",
4040
"64950a634cd11d1a01ddfedaeffed67b531cb11e^!",
4141
"--name-only",
42+
"-z",
4243
],
4344
cwd="/bin",
4445
)
@@ -50,7 +51,7 @@ async def test_changed_files_working_tree():
5051
with patch("jupyterlab_git.git.execute") as mock_execute:
5152
# Given
5253
mock_execute.return_value = tornado.gen.maybe_future(
53-
(0, "file1.ipynb\nfile2.py", "")
54+
(0, "file1.ipynb\x00file2.py", "")
5455
)
5556

5657
# When
@@ -60,7 +61,7 @@ async def test_changed_files_working_tree():
6061

6162
# Then
6263
mock_execute.assert_called_once_with(
63-
["git", "diff", "HEAD", "--name-only"], cwd="/bin"
64+
["git", "diff", "HEAD", "--name-only", "-z"], cwd="/bin"
6465
)
6566
assert {"code": 0, "files": ["file1.ipynb", "file2.py"]} == actual_response
6667

@@ -70,7 +71,7 @@ async def test_changed_files_index():
7071
with patch("jupyterlab_git.git.execute") as mock_execute:
7172
# Given
7273
mock_execute.return_value = tornado.gen.maybe_future(
73-
(0, "file1.ipynb\nfile2.py", "")
74+
(0, "file1.ipynb\x00file2.py", "")
7475
)
7576

7677
# When
@@ -80,7 +81,7 @@ async def test_changed_files_index():
8081

8182
# Then
8283
mock_execute.assert_called_once_with(
83-
["git", "diff", "--staged", "HEAD", "--name-only"], cwd="/bin"
84+
["git", "diff", "--staged", "HEAD", "--name-only", "-z"], cwd="/bin"
8485
)
8586
assert {"code": 0, "files": ["file1.ipynb", "file2.py"]} == actual_response
8687

@@ -90,7 +91,7 @@ async def test_changed_files_two_commits():
9091
with patch("jupyterlab_git.git.execute") as mock_execute:
9192
# Given
9293
mock_execute.return_value = tornado.gen.maybe_future(
93-
(0, "file1.ipynb\nfile2.py", "")
94+
(0, "file1.ipynb\x00file2.py", "")
9495
)
9596

9697
# When
@@ -100,7 +101,7 @@ async def test_changed_files_two_commits():
100101

101102
# Then
102103
mock_execute.assert_called_once_with(
103-
["git", "diff", "HEAD", "origin/HEAD", "--name-only"], cwd="/bin"
104+
["git", "diff", "HEAD", "origin/HEAD", "--name-only", "-z"], cwd="/bin"
104105
)
105106
assert {"code": 0, "files": ["file1.ipynb", "file2.py"]} == actual_response
106107

@@ -118,6 +119,6 @@ async def test_changed_files_git_diff_error():
118119

119120
# Then
120121
mock_execute.assert_called_once_with(
121-
["git", "diff", "HEAD", "origin/HEAD", "--name-only"], cwd="/bin"
122+
["git", "diff", "HEAD", "origin/HEAD", "--name-only", "-z"], cwd="/bin"
122123
)
123124
assert {"code": 128, "message": "error message"} == actual_response

0 commit comments

Comments
 (0)