summaryrefslogtreecommitdiffstats
path: root/pkg/commands/loading_files_test.go
diff options
context:
space:
mode:
authormjarkk <mkopenga@gmail.com>2021-07-22 12:02:41 +0200
committermjarkk <mkopenga@gmail.com>2021-07-22 22:12:43 +0200
commit9a087d04ebaed311e0bd3d9cbd32dd2973f0406c (patch)
tree7e0fd92807348112b9ac850424d4469711322af3 /pkg/commands/loading_files_test.go
parent1573a449f84846657b7ac9e07756caa9db548b0e (diff)
Change the way file statuses are loaded
This makes it so file statuses recived from git no longer get joined before spliting them again.
Diffstat (limited to 'pkg/commands/loading_files_test.go')
-rw-r--r--pkg/commands/loading_files_test.go34
1 files changed, 32 insertions, 2 deletions
diff --git a/pkg/commands/loading_files_test.go b/pkg/commands/loading_files_test.go
index bb0a5971a..eefb8f924 100644
--- a/pkg/commands/loading_files_test.go
+++ b/pkg/commands/loading_files_test.go
@@ -31,8 +31,8 @@ func TestGitCommandGetStatusFiles(t *testing.T) {
"Several files found",
func(cmd string, args ...string) *exec.Cmd {
return secureexec.Command(
- "echo",
- "MM file1.txt\nA file3.txt\nAM file2.txt\n?? file4.txt\nUU file5.txt",
+ "printf",
+ `MM file1.txt\0A file3.txt\0AM file2.txt\0?? file4.txt\0UU file5.txt`,
)
},
func(files []*models.File) {
@@ -109,6 +109,36 @@ func TestGitCommandGetStatusFiles(t *testing.T) {
assert.EqualValues(t, expected, files)
},
},
+ {
+ "File with new line char",
+ func(cmd string, args ...string) *exec.Cmd {
+ return secureexec.Command(
+ "printf",
+ `MM a\nb.txt`,
+ )
+ },
+ func(files []*models.File) {
+ assert.Len(t, files, 1)
+
+ expected := []*models.File{
+ {
+ Name: "a\nb.txt",
+ HasStagedChanges: true,
+ HasUnstagedChanges: true,
+ Tracked: true,
+ Added: false,
+ Deleted: false,
+ HasMergeConflicts: false,
+ HasInlineMergeConflicts: false,
+ DisplayString: "MM a\nb.txt",
+ Type: "other",
+ ShortStatus: "MM",
+ },
+ }
+
+ assert.EqualValues(t, expected, files)
+ },
+ },
}
for _, s := range scenarios {