@@ -200,7 +200,7 @@ describe('opencode.core', function()
200200 it (' resets is_opening flag when error occurs' , function ()
201201 state .windows = nil
202202 state .is_opening = false
203-
203+
204204 -- Simply cause an error by stubbing a function that will be called
205205 local original_create_new_session = core .create_new_session
206206 core .create_new_session = function ()
@@ -209,7 +209,7 @@ describe('opencode.core', function()
209209
210210 local notify_stub = stub (vim , ' notify' )
211211 local result_promise = core .open ({ new_session = true , focus = ' input' })
212-
212+
213213 -- Wait for async operations to complete
214214 local ok , err = pcall (function ()
215215 result_promise :wait ()
@@ -218,13 +218,13 @@ describe('opencode.core', function()
218218 -- Should fail due to the error
219219 assert .is_false (ok )
220220 assert .truthy (err )
221-
221+
222222 -- is_opening should be reset to false even when error occurs
223223 assert .is_false (state .is_opening )
224-
224+
225225 -- Should have notified about the error
226226 assert .stub (notify_stub ).was_called ()
227-
227+
228228 -- Restore original function
229229 core .create_new_session = original_create_new_session
230230 notify_stub :revert ()
@@ -405,7 +405,12 @@ describe('opencode.core', function()
405405 local saved_cli
406406
407407 local function mock_vim_system (result )
408- return function (_cmd , _opts )
408+ return function (_cmd , _opts , on_exit )
409+ if on_exit then
410+ result .code = 0
411+ on_exit (result )
412+ end
413+
409414 return {
410415 wait = function ()
411416 return result
@@ -430,7 +435,7 @@ describe('opencode.core', function()
430435 vim .fn .executable = function (_ )
431436 return 0
432437 end
433- assert .is_false (core .opencode_ok ())
438+ assert .is_false (core .opencode_ok (): await () )
434439 end )
435440
436441 it (' returns false when version is below required' , function ()
@@ -440,7 +445,7 @@ describe('opencode.core', function()
440445 vim .system = mock_vim_system ({ stdout = ' opencode 0.4.1' })
441446 state .opencode_cli_version = nil
442447 state .required_version = ' 0.4.2'
443- assert .is_false (core .opencode_ok ())
448+ assert .is_false (core .opencode_ok (): await () )
444449 end )
445450
446451 it (' returns true when version equals required' , function ()
@@ -450,7 +455,7 @@ describe('opencode.core', function()
450455 vim .system = mock_vim_system ({ stdout = ' opencode 0.4.2' })
451456 state .opencode_cli_version = nil
452457 state .required_version = ' 0.4.2'
453- assert .is_true (core .opencode_ok ())
458+ assert .is_true (core .opencode_ok (): await () )
454459 end )
455460
456461 it (' returns true when version is above required' , function ()
@@ -460,7 +465,7 @@ describe('opencode.core', function()
460465 vim .system = mock_vim_system ({ stdout = ' opencode 0.5.0' })
461466 state .opencode_cli_version = nil
462467 state .required_version = ' 0.4.2'
463- assert .is_true (core .opencode_ok ())
468+ assert .is_true (core .opencode_ok (): await () )
464469 end )
465470 end )
466471
@@ -477,7 +482,7 @@ describe('opencode.core', function()
477482 },
478483 },
479484 })
480-
485+
481486 stub (config_file , ' get_opencode_agents' ).returns (agents_promise )
482487 stub (config_file , ' get_opencode_config' ).returns (config_promise )
483488
@@ -505,7 +510,7 @@ describe('opencode.core', function()
505510 plan = {},
506511 },
507512 })
508-
513+
509514 stub (config_file , ' get_opencode_agents' ).returns (agents_promise )
510515 stub (config_file , ' get_opencode_config' ).returns (config_promise )
511516
@@ -527,7 +532,7 @@ describe('opencode.core', function()
527532 local Promise = require (' opencode.promise' )
528533 local agents_promise = Promise .new ()
529534 agents_promise :resolve ({ ' plan' , ' build' })
530-
535+
531536 stub (config_file , ' get_opencode_agents' ).returns (agents_promise )
532537
533538 local promise = core .switch_to_mode (' nonexistent' )
0 commit comments