@@ -11,29 +11,35 @@ import (
1111
1212func  TestFileGetStatusFiles (t  * testing.T ) {
1313	type  scenario  struct  {
14- 		testName             string 
15- 		similarityThreshold  int 
16- 		runner               oscommands.ICmdObjRunner 
17- 		expectedFiles        []* models.File 
14+ 		testName                string 
15+ 		similarityThreshold     int 
16+ 		runner                  oscommands.ICmdObjRunner 
17+ 		showNumstatInFilesView  bool 
18+ 		expectedFiles           []* models.File 
1819	}
1920
2021	scenarios  :=  []scenario {
2122		{
22- 			"No files found" ,
23- 			50 ,
24- 			oscommands .NewFakeRunner (t ).
23+ 			testName :             "No files found" ,
24+ 			similarityThreshold :  50 ,
25+ 			runner :  oscommands .NewFakeRunner (t ).
2526				ExpectGitArgs ([]string {"status" , "--untracked-files=yes" , "--porcelain" , "-z" , "--find-renames=50%" }, "" , nil ),
26- 			[]* models.File {},
27+ 			expectedFiles :  []* models.File {},
2728		},
2829		{
29- 			"Several files found" ,
30- 			50 ,
31- 			oscommands .NewFakeRunner (t ).
30+ 			testName :             "Several files found" ,
31+ 			similarityThreshold :  50 ,
32+ 			runner :  oscommands .NewFakeRunner (t ).
3233				ExpectGitArgs ([]string {"status" , "--untracked-files=yes" , "--porcelain" , "-z" , "--find-renames=50%" },
3334					"MM file1.txt\x00 A  file3.txt\x00 AM file2.txt\x00 ?? file4.txt\x00 UU file5.txt" ,
3435					nil ,
36+ 				).
37+ 				ExpectGitArgs ([]string {"diff" , "--numstat" , "-z" , "HEAD" },
38+ 					"4\t 1\t file1.txt\x00 1\t 0\t file2.txt\x00 2\t 2\t file3.txt\x00 0\t 2\t file4.txt\x00 2\t 2\t file5.txt" ,
39+ 					nil ,
3540				),
36- 			[]* models.File {
41+ 			showNumstatInFilesView : true ,
42+ 			expectedFiles : []* models.File {
3743				{
3844					Name :                    "file1.txt" ,
3945					HasStagedChanges :        true ,
@@ -45,6 +51,8 @@ func TestFileGetStatusFiles(t *testing.T) {
4551					HasInlineMergeConflicts : false ,
4652					DisplayString :           "MM file1.txt" ,
4753					ShortStatus :             "MM" ,
54+ 					LinesAdded :              4 ,
55+ 					LinesDeleted :            1 ,
4856				},
4957				{
5058					Name :                    "file3.txt" ,
@@ -57,6 +65,8 @@ func TestFileGetStatusFiles(t *testing.T) {
5765					HasInlineMergeConflicts : false ,
5866					DisplayString :           "A  file3.txt" ,
5967					ShortStatus :             "A " ,
68+ 					LinesAdded :              2 ,
69+ 					LinesDeleted :            2 ,
6070				},
6171				{
6272					Name :                    "file2.txt" ,
@@ -69,6 +79,8 @@ func TestFileGetStatusFiles(t *testing.T) {
6979					HasInlineMergeConflicts : false ,
7080					DisplayString :           "AM file2.txt" ,
7181					ShortStatus :             "AM" ,
82+ 					LinesAdded :              1 ,
83+ 					LinesDeleted :            0 ,
7284				},
7385				{
7486					Name :                    "file4.txt" ,
@@ -81,6 +93,8 @@ func TestFileGetStatusFiles(t *testing.T) {
8193					HasInlineMergeConflicts : false ,
8294					DisplayString :           "?? file4.txt" ,
8395					ShortStatus :             "??" ,
96+ 					LinesAdded :              0 ,
97+ 					LinesDeleted :            2 ,
8498				},
8599				{
86100					Name :                    "file5.txt" ,
@@ -93,15 +107,17 @@ func TestFileGetStatusFiles(t *testing.T) {
93107					HasInlineMergeConflicts : true ,
94108					DisplayString :           "UU file5.txt" ,
95109					ShortStatus :             "UU" ,
110+ 					LinesAdded :              2 ,
111+ 					LinesDeleted :            2 ,
96112				},
97113			},
98114		},
99115		{
100- 			"File with new line char" ,
101- 			50 ,
102- 			oscommands .NewFakeRunner (t ).
116+ 			testName :             "File with new line char" ,
117+ 			similarityThreshold :  50 ,
118+ 			runner :  oscommands .NewFakeRunner (t ).
103119				ExpectGitArgs ([]string {"status" , "--untracked-files=yes" , "--porcelain" , "-z" , "--find-renames=50%" }, "MM a\n b.txt" , nil ),
104- 			[]* models.File {
120+ 			expectedFiles :  []* models.File {
105121				{
106122					Name :                    "a\n b.txt" ,
107123					HasStagedChanges :        true ,
@@ -117,14 +133,14 @@ func TestFileGetStatusFiles(t *testing.T) {
117133			},
118134		},
119135		{
120- 			"Renamed files" ,
121- 			50 ,
122- 			oscommands .NewFakeRunner (t ).
136+ 			testName :             "Renamed files" ,
137+ 			similarityThreshold :  50 ,
138+ 			runner :  oscommands .NewFakeRunner (t ).
123139				ExpectGitArgs ([]string {"status" , "--untracked-files=yes" , "--porcelain" , "-z" , "--find-renames=50%" },
124140					"R  after1.txt\x00 before1.txt\x00 RM after2.txt\x00 before2.txt" ,
125141					nil ,
126142				),
127- 			[]* models.File {
143+ 			expectedFiles :  []* models.File {
128144				{
129145					Name :                    "after1.txt" ,
130146					PreviousName :            "before1.txt" ,
@@ -154,14 +170,14 @@ func TestFileGetStatusFiles(t *testing.T) {
154170			},
155171		},
156172		{
157- 			"File with arrow in name" ,
158- 			50 ,
159- 			oscommands .NewFakeRunner (t ).
173+ 			testName :             "File with arrow in name" ,
174+ 			similarityThreshold :  50 ,
175+ 			runner :  oscommands .NewFakeRunner (t ).
160176				ExpectGitArgs ([]string {"status" , "--untracked-files=yes" , "--porcelain" , "-z" , "--find-renames=50%" },
161177					`?? a -> b.txt` ,
162178					nil ,
163179				),
164- 			[]* models.File {
180+ 			expectedFiles :  []* models.File {
165181				{
166182					Name :                    "a -> b.txt" ,
167183					HasStagedChanges :        false ,
@@ -185,8 +201,14 @@ func TestFileGetStatusFiles(t *testing.T) {
185201			appState  :=  & config.AppState {}
186202			appState .RenameSimilarityThreshold  =  s .similarityThreshold 
187203
204+ 			userConfig  :=  & config.UserConfig {
205+ 				Gui : config.GuiConfig {
206+ 					ShowNumstatInFilesView : s .showNumstatInFilesView ,
207+ 				},
208+ 			}
209+ 
188210			loader  :=  & FileLoader {
189- 				GitCommon :   buildGitCommon (commonDeps {appState : appState }),
211+ 				GitCommon :   buildGitCommon (commonDeps {appState : appState ,  userConfig :  userConfig }),
190212				cmd :         cmd ,
191213				config :      & FakeFileLoaderConfig {showUntrackedFiles : "yes" },
192214				getFileType : func (string ) string  { return  "file"  },
0 commit comments