@@ -134,7 +134,7 @@ describe("discover_positions", function()
134
134
id = vim .loop .cwd () .. " /neotest_go/cases_test.go" ,
135
135
name = " cases_test.go" ,
136
136
path = vim .loop .cwd () .. " /neotest_go/cases_test.go" ,
137
- range = { 0 , 0 , 49 , 0 },
137
+ range = { 0 , 0 , 55 , 0 },
138
138
type = " file" ,
139
139
},
140
140
{
@@ -169,7 +169,7 @@ describe("discover_positions", function()
169
169
id = vim .loop .cwd () .. " /neotest_go/cases_test.go::TestAdd" ,
170
170
name = " TestAdd" ,
171
171
path = vim .loop .cwd () .. " /neotest_go/cases_test.go" ,
172
- range = { 35 , 0 , 48 , 1 },
172
+ range = { 35 , 0 , 54 , 1 },
173
173
type = " test" ,
174
174
},
175
175
{
@@ -190,9 +190,29 @@ describe("discover_positions", function()
190
190
type = " test" ,
191
191
},
192
192
},
193
+ {
194
+ {
195
+ id = vim .loop .cwd () .. " /neotest_go/cases_test.go::TestAdd::test_three" ,
196
+ name = ' "test three"' ,
197
+ path = vim .loop .cwd () .. " /neotest_go/cases_test.go" ,
198
+ range = { 44 , 1 , 48 , 3 },
199
+ type = " test" ,
200
+ },
201
+ {
202
+ {
203
+ id = vim .loop .cwd () .. " /neotest_go/cases_test.go::TestAdd::\" test three\" ::test_four" ,
204
+ name = ' "test four"' ,
205
+ path = vim .loop .cwd () .. " /neotest_go/cases_test.go" ,
206
+ range = { 45 , 2 , 47 , 4 },
207
+ type = " test" ,
208
+ },
209
+ },
210
+ },
193
211
},
194
212
}
195
213
214
+ assert :set_parameter (" TableFormatLevel" , 6 )
215
+
196
216
assert .are .same (positions , expected_positions )
197
217
end )
198
218
async .it (" discovers positions in unit tests in map_table_test.go" , function ()
@@ -334,7 +354,7 @@ describe("prepare_results", function()
334
354
table.insert (lines , s )
335
355
end
336
356
local processed_results =
337
- plugin .prepare_results (positions , lines , tests_folder , " neotest_go" )
357
+ plugin .prepare_results (positions , lines , tests_folder , " neotest_go" )
338
358
339
359
assert .equals (test_result .status , processed_results [test_file ].status )
340
360
end )
@@ -349,8 +369,8 @@ describe("build_spec", function()
349
369
350
370
local args = { tree = tree }
351
371
local expected_command = " cd "
352
- .. vim .loop .cwd ()
353
- .. " /neotest_go && go test -v -json -count=1 -timeout=60s ./"
372
+ .. vim .loop .cwd ()
373
+ .. " /neotest_go && go test -v -json -count=1 -timeout=60s ./"
354
374
local result = plugin .build_spec (args )
355
375
assert .are .same (expected_command , result .command )
356
376
assert .are .same (path , result .context .file )
@@ -361,23 +381,36 @@ describe("build_spec", function()
361
381
362
382
local args = { tree = tree }
363
383
local expected_command = " cd "
364
- .. vim .loop .cwd ()
365
- .. " /neotest_go && go test -v -json -count=1 -timeout=60s - -run ^TestAddOne$ ./"
384
+ .. vim .loop .cwd ()
385
+ .. " /neotest_go && go test -v -json -count=1 -timeout=60s -run ^TestAddOne$ ./"
366
386
local result = plugin .build_spec (args )
367
387
assert .are .same (expected_command , result .command )
368
388
assert .are .same (path , result .context .file )
369
389
end )
370
390
371
- -- This test is overwriting plugin global state, keep it at end of the file or face the consequences ¯\_(ツ)_/¯
391
+ async .it (" build specification for single nested test" , function ()
392
+ local path = vim .loop .cwd () .. " /neotest_go/cases_test.go"
393
+ local tree = plugin .discover_positions (path )
394
+ local test_tree = tree :children ()[2 ]:children ()[3 ]:children ()[1 ]
395
+
396
+ local args = { tree = test_tree }
397
+ local expected_command = " cd "
398
+ .. vim .loop .cwd ()
399
+ .. " /neotest_go && go test -v -json -count=1 -timeout=60s -run ^TestAdd/test_three/test_four$ ./"
400
+ local result = plugin .build_spec (args )
401
+ assert .are .same (expected_command , result .command )
402
+ assert .are .same (path , result .context .file )
403
+ end )
404
+ -- This test is overwriting plugin global state, keep it at end of the file or face the consequences ¯\_(ツ)_/¯
372
405
async .it (" build specification for many_table_test.go recuresive run" , function ()
373
406
local plugin_with_recursive_run = require (" neotest-go" )({ recursive_run = true })
374
407
local path = vim .loop .cwd () .. " /neotest_go/many_table_test.go"
375
408
local tree = plugin .discover_positions (path )
376
409
377
410
local args = { tree = tree }
378
411
local expected_command = " cd "
379
- .. vim .loop .cwd ()
380
- .. " /neotest_go && go test -v -json -count=1 -timeout=60s ./..."
412
+ .. vim .loop .cwd ()
413
+ .. " /neotest_go && go test -v -json -count=1 -timeout=60s ./..."
381
414
local result = plugin_with_recursive_run .build_spec (args )
382
415
assert .are .same (expected_command , result .command )
383
416
assert .are .same (path , result .context .file )
0 commit comments