@@ -196,5 +196,113 @@ describe("Configuration", function()
196
196
expect (success ).to_be_false ()
197
197
end )
198
198
199
+ it (" should accept function for external_terminal_cmd" , function ()
200
+ local valid_config = {
201
+ port_range = { min = 10000 , max = 65535 },
202
+ auto_start = true ,
203
+ log_level = " info" ,
204
+ track_selection = true ,
205
+ visual_demotion_delay_ms = 50 ,
206
+ connection_wait_delay = 200 ,
207
+ connection_timeout = 10000 ,
208
+ queue_timeout = 5000 ,
209
+ diff_opts = {
210
+ auto_close_on_accept = true ,
211
+ show_diff_stats = true ,
212
+ vertical_split = true ,
213
+ open_in_current_tab = true ,
214
+ },
215
+ env = {},
216
+ models = {
217
+ { name = " Test Model" , value = " test" },
218
+ },
219
+ terminal = {
220
+ provider = " external" ,
221
+ provider_opts = {
222
+ external_terminal_cmd = function (cmd , env )
223
+ return " terminal " .. cmd
224
+ end ,
225
+ },
226
+ },
227
+ }
228
+
229
+ local success , _ = pcall (function ()
230
+ config .validate (valid_config )
231
+ end )
232
+
233
+ expect (success ).to_be_true ()
234
+ end )
235
+
236
+ it (" should accept string for external_terminal_cmd" , function ()
237
+ local valid_config = {
238
+ port_range = { min = 10000 , max = 65535 },
239
+ auto_start = true ,
240
+ log_level = " info" ,
241
+ track_selection = true ,
242
+ visual_demotion_delay_ms = 50 ,
243
+ connection_wait_delay = 200 ,
244
+ connection_timeout = 10000 ,
245
+ queue_timeout = 5000 ,
246
+ diff_opts = {
247
+ auto_close_on_accept = true ,
248
+ show_diff_stats = true ,
249
+ vertical_split = true ,
250
+ open_in_current_tab = true ,
251
+ },
252
+ env = {},
253
+ models = {
254
+ { name = " Test Model" , value = " test" },
255
+ },
256
+ terminal = {
257
+ provider = " external" ,
258
+ provider_opts = {
259
+ external_terminal_cmd = " alacritty -e %s" ,
260
+ },
261
+ },
262
+ }
263
+
264
+ local success , _ = pcall (function ()
265
+ config .validate (valid_config )
266
+ end )
267
+
268
+ expect (success ).to_be_true ()
269
+ end )
270
+
271
+ it (" should reject invalid type for external_terminal_cmd" , function ()
272
+ local invalid_config = {
273
+ port_range = { min = 10000 , max = 65535 },
274
+ auto_start = true ,
275
+ log_level = " info" ,
276
+ track_selection = true ,
277
+ visual_demotion_delay_ms = 50 ,
278
+ connection_wait_delay = 200 ,
279
+ connection_timeout = 10000 ,
280
+ queue_timeout = 5000 ,
281
+ diff_opts = {
282
+ auto_close_on_accept = true ,
283
+ show_diff_stats = true ,
284
+ vertical_split = true ,
285
+ open_in_current_tab = true ,
286
+ },
287
+ env = {},
288
+ models = {
289
+ { name = " Test Model" , value = " test" },
290
+ },
291
+ terminal = {
292
+ provider = " external" ,
293
+ provider_opts = {
294
+ external_terminal_cmd = 123 , -- Invalid: number
295
+ },
296
+ },
297
+ }
298
+
299
+ local success , err = pcall (function ()
300
+ config .validate (invalid_config )
301
+ end )
302
+
303
+ expect (success ).to_be_false ()
304
+ expect (err ).to_match (" must be a string or function" )
305
+ end )
306
+
199
307
teardown ()
200
308
end )
0 commit comments