@@ -10,6 +10,7 @@ local M = {}
10
10
11
11
--- @class GnoTestCtx
12
12
--- @field is_unit ? boolean
13
+ --- @field is_golden ? boolean
13
14
--- @field file ? string
14
15
--- @field testcase ? string
15
16
--- @field label string
@@ -32,6 +33,7 @@ local function get_test_context()
32
33
if is_unit or is_golden then
33
34
return {
34
35
is_unit = is_unit ,
36
+ is_golden = is_golden ,
35
37
file = vim .fn .fnamemodify (current_file , " :t" ),
36
38
label = vim .fn .fnamemodify (current_file , " :." ),
37
39
dir = dirname ,
@@ -102,7 +104,13 @@ local function show_test_picker(ctx, gno_opts, opts)
102
104
local bufnr = vim .api .nvim_get_current_buf ()
103
105
local row , _ = unpack (vim .api .nvim_win_get_cursor (0 ))
104
106
105
- local options = queries .find_test_cases (bufnr , row )
107
+ local options
108
+ if ctx .is_unit then
109
+ options = queries .find_test_cases (bufnr , row )
110
+ else
111
+ options = { " file/" .. ctx .file }
112
+ end
113
+
106
114
if not options or # options == 0 then
107
115
call_gnotest ({
108
116
label = ctx .label ,
@@ -165,7 +173,7 @@ function M.run_command(opts, gno_opts)
165
173
verb = { ctx .file or " ." }
166
174
test_label = ctx .label
167
175
168
- if ctx .is_unit then
176
+ if ctx .is_unit or ctx . is_golden then
169
177
show_test_picker (ctx , gno_opts , opts )
170
178
return
171
179
end
0 commit comments