@@ -13,29 +13,13 @@ local function setup_test_environment()
1313 table.insert (_G .notifications , { message = message , level = level , opts = opts })
1414 end
1515 _G .server = require (" eca.server" ).new ()
16-
1716end
1817
1918local T = MiniTest .new_set ({
2019 hooks = {
2120 pre_case = function ()
2221 child .restart ({ " -u" , " scripts/minimal_init.lua" })
2322 child .lua_func (setup_test_environment )
24- child .lua ([[
25- package.preload["eca.path_finder"] = function()
26- local M = {}
27-
28- function M.new()
29- return setmetatable({}, { __index = M })
30- end
31-
32- function M.find(arg)
33- return ":" -- do nothing
34- end
35-
36- return M
37- end
38- ]] )
3923 end ,
4024 post_case = function ()
4125 child .lua (" if _G.server and _G.server.process then _G.server.process:kill() end" )
@@ -54,70 +38,29 @@ local function sleep(ms)
5438end
5539
5640T [" server" ] = MiniTest .new_set ()
41+
5742T [" server" ][" start" ] = function ()
58- child .lua (" _G.server.start()" )
59- eq (child .lua_get (" _G.server.process" ), vim .NIL )
60- child .lua ([[
61- _G.server:start()
62- _G.server_started = vim.wait(5000, function()
43+ child .lua (" _G.server:start()" )
44+ child .lua ([[
45+ _G.server_started = vim.wait(10000, function()
6346 return _G.server and _G.server:is_running()
64- end, 50 )
47+ end, 100 )
6548 ]] )
6649 eq (child .lua_get (" _G.server_started" ), true )
50+ sleep (1000 )
51+ eq (child .lua_get (" _G.server.initialized" ), true )
6752end
6853
69- T [" server" ][" initialize" ] = function ()
70- local test_cases = {
71- {
72- method = " initialize" ,
73- want = {
74- chatBehaviors = { " agent" , " plan" },
75- chatDefaultBehavior = " agent" ,
76- chatDefaultModel = " anthropic/claude-sonnet-4-20250514" ,
77- chatWelcomeMessage = " Welcome to ECA!\n\n Type '/' for commands\n\n " ,
78- models = {
79- " anthropic/claude-3-5-haiku-20241022" ,
80- " anthropic/claude-opus-4-1-20250805" ,
81- " anthropic/claude-opus-4-20250514" ,
82- " anthropic/claude-sonnet-4-20250514" ,
83- " github-copilot/claude-sonnet-4" ,
84- " github-copilot/gpt-4.1" ,
85- " github-copilot/gpt-5" ,
86- " github-copilot/gpt-5-mini" ,
87- " openai/gpt-4.1" ,
88- " openai/gpt-5" ,
89- " openai/gpt-5-mini" ,
90- " openai/gpt-5-nano" ,
91- " openai/o3" ,
92- " openai/o4-mini" ,
93- },
94- },
95- },
96- { method = " not a command" , want = vim .NIL },
97- }
98- for i , test_case in ipairs (test_cases ) do
99- if i == 1 then
100- test_case = test_cases [i + 1 ]
101- end
102- child .lua (" _G.method = " .. vim .inspect (test_case .method ))
103- child .lua (" _G.server:start({initialize = false})" )
104- -- Wait for async server start
105- child .lua ([[
106- _G.server_started = vim.wait(5000, function()
107- return _G.server and _G.server:is_running()
108- end, 50)
109- ]] )
110- eq (child .lua_get (" _G.server_started" ), true )
111-
112- child .lua_func (function ()
113- _G .server :send_request (_G .method , {}, function (err , result )
114- _G .err = err
115- _G .result = result
116- end )
117- end )
118- sleep (1500 )
119- eq (child .lua_get (" _G.result" ), test_case .want )
120- end
54+ T [" server" ][" start without initialize" ] = function ()
55+ child .lua (" _G.server:start({ initialize = false })" )
56+ child .lua ([[
57+ _G.server_started = vim.wait(10000, function()
58+ return _G.server and _G.server:is_running()
59+ end, 100)
60+ ]] )
61+ eq (child .lua_get (" _G.server_started" ), true )
62+ sleep (1000 )
63+ eq (child .lua_get (" _G.server.initialized" ), false )
12164end
12265
12366return T
0 commit comments