@@ -7,10 +7,18 @@ describe('worktree_command:', function()
77 local function make_mock_repo (overrides )
88 overrides = overrides or {}
99 return {
10- get_path = function () return ' /tmp/repo' end ,
11- worktree_add = overrides .worktree_add or function () return {}, nil end ,
12- worktree_remove = overrides .worktree_remove or function () return {}, nil end ,
13- worktree_list = overrides .worktree_list or function () return {}, nil end ,
10+ get_path = function ()
11+ return ' /tmp/repo'
12+ end ,
13+ worktree_add = overrides .worktree_add or function ()
14+ return {}, nil
15+ end ,
16+ worktree_remove = overrides .worktree_remove or function ()
17+ return {}, nil
18+ end ,
19+ worktree_list = overrides .worktree_list or function ()
20+ return {}, nil
21+ end ,
1422 }
1523 end
1624
@@ -20,13 +28,16 @@ describe('worktree_command:', function()
2028 save_package (' vgit.git.repository' )
2129 package.loaded [' vgit.git.repository' ] = overrides .repository
2230 or {
23- current = function () return make_mock_repo (overrides .repo_methods ), nil end ,
31+ current = function ()
32+ return make_mock_repo (overrides .repo_methods ), nil
33+ end ,
2434 }
2535
2636 save_package (' vgit.ui.display_service' )
27- package.loaded [' vgit.ui.display_service' ] = overrides .display_service or {
28- show_worktree = function () end ,
29- }
37+ package.loaded [' vgit.ui.display_service' ] = overrides .display_service
38+ or {
39+ show_worktree = function () end ,
40+ }
3041
3142 save_package (' vgit.core.console' )
3243 package.loaded [' vgit.core.console' ] = overrides .console
@@ -53,10 +64,14 @@ describe('worktree_command:', function()
5364 local worktrees = { { path = ' /tmp/wt' , head = ' abc' , branch = ' feat' } }
5465 setup_defaults ({
5566 repo_methods = {
56- worktree_list = function () return worktrees , nil end ,
67+ worktree_list = function ()
68+ return worktrees , nil
69+ end ,
5770 },
5871 display_service = {
59- show_worktree = function (data ) show_data = data end ,
72+ show_worktree = function (data )
73+ show_data = data
74+ end ,
6075 },
6176 })
6277 load_cmd ().execute ({})
@@ -114,10 +129,14 @@ describe('worktree_command:', function()
114129 local error_msg = nil
115130 setup_defaults ({
116131 repository = {
117- current = function () return nil , ' not a git repository' end ,
132+ current = function ()
133+ return nil , ' not a git repository'
134+ end ,
118135 },
119136 console = {
120- error = function (msg ) error_msg = msg end ,
137+ error = function (msg )
138+ error_msg = msg
139+ end ,
121140 info = function () end ,
122141 },
123142 })
@@ -129,7 +148,9 @@ describe('worktree_command:', function()
129148 local error_msg = nil
130149 setup_defaults ({
131150 console = {
132- error = function (msg ) error_msg = msg end ,
151+ error = function (msg )
152+ error_msg = msg
153+ end ,
133154 info = function () end ,
134155 },
135156 })
@@ -141,7 +162,9 @@ describe('worktree_command:', function()
141162 local error_msg = nil
142163 setup_defaults ({
143164 console = {
144- error = function (msg ) error_msg = msg end ,
165+ error = function (msg )
166+ error_msg = msg
167+ end ,
145168 info = function () end ,
146169 },
147170 })
@@ -153,7 +176,9 @@ describe('worktree_command:', function()
153176 local error_msg = nil
154177 setup_defaults ({
155178 console = {
156- error = function (msg ) error_msg = msg end ,
179+ error = function (msg )
180+ error_msg = msg
181+ end ,
157182 info = function () end ,
158183 },
159184 })
@@ -165,10 +190,14 @@ describe('worktree_command:', function()
165190 local error_msg = nil
166191 setup_defaults ({
167192 repo_methods = {
168- worktree_add = function () return nil , { ' fatal: path already exists' } end ,
193+ worktree_add = function ()
194+ return nil , { ' fatal: path already exists' }
195+ end ,
169196 },
170197 console = {
171- error = function (msg ) error_msg = msg end ,
198+ error = function (msg )
199+ error_msg = msg
200+ end ,
172201 info = function () end ,
173202 },
174203 })
@@ -180,10 +209,14 @@ describe('worktree_command:', function()
180209 local error_msg = nil
181210 setup_defaults ({
182211 repo_methods = {
183- worktree_remove = function () return nil , { ' fatal: not a valid worktree' } end ,
212+ worktree_remove = function ()
213+ return nil , { ' fatal: not a valid worktree' }
214+ end ,
184215 },
185216 console = {
186- error = function (msg ) error_msg = msg end ,
217+ error = function (msg )
218+ error_msg = msg
219+ end ,
187220 info = function () end ,
188221 },
189222 })
@@ -195,10 +228,14 @@ describe('worktree_command:', function()
195228 local error_msg = nil
196229 setup_defaults ({
197230 repo_methods = {
198- worktree_list = function () return nil , { ' failed to list' } end ,
231+ worktree_list = function ()
232+ return nil , { ' failed to list' }
233+ end ,
199234 },
200235 console = {
201- error = function (msg ) error_msg = msg end ,
236+ error = function (msg )
237+ error_msg = msg
238+ end ,
202239 info = function () end ,
203240 },
204241 })
@@ -210,11 +247,15 @@ describe('worktree_command:', function()
210247 local info_msg = nil
211248 setup_defaults ({
212249 repo_methods = {
213- worktree_list = function () return {}, nil end ,
250+ worktree_list = function ()
251+ return {}, nil
252+ end ,
214253 },
215254 console = {
216255 error = function () end ,
217- info = function (msg ) info_msg = msg end ,
256+ info = function (msg )
257+ info_msg = msg
258+ end ,
218259 },
219260 })
220261 load_cmd ().execute ({})
@@ -227,11 +268,15 @@ describe('worktree_command:', function()
227268 local info_msg = nil
228269 setup_defaults ({
229270 repo_methods = {
230- worktree_add = function () return {}, nil end ,
271+ worktree_add = function ()
272+ return {}, nil
273+ end ,
231274 },
232275 console = {
233276 error = function () end ,
234- info = function (msg ) info_msg = msg end ,
277+ info = function (msg )
278+ info_msg = msg
279+ end ,
235280 },
236281 })
237282 load_cmd ().execute ({ ' add' , ' /tmp/new-wt' })
@@ -242,11 +287,15 @@ describe('worktree_command:', function()
242287 local info_msg = nil
243288 setup_defaults ({
244289 repo_methods = {
245- worktree_remove = function () return {}, nil end ,
290+ worktree_remove = function ()
291+ return {}, nil
292+ end ,
246293 },
247294 console = {
248295 error = function () end ,
249- info = function (msg ) info_msg = msg end ,
296+ info = function (msg )
297+ info_msg = msg
298+ end ,
250299 },
251300 })
252301 load_cmd ().execute ({ ' remove' , ' /tmp/old-wt' })
0 commit comments