@@ -2,9 +2,10 @@ local child_helper = require("tests.child_helper")
22local child = child_helper .new_child_neovim (" test_auth" )
33local u = require (" tests.utils" )
44
5- local config_path = require (" copilot.auth" ).find_config_path ()
5+ local config_path = require (" copilot.auth" ).find_config_path () .. " /github-copilot "
66local config_path_renamed = config_path .. " _temp_renamed"
77
8+ -- TODO: find a way to not mess with folders
89local T = MiniTest .new_set ({
910 hooks = {
1011 pre_once = function ()
@@ -14,13 +15,6 @@ local T = MiniTest.new_set({
1415 end ,
1516 pre_case = function ()
1617 child .run_pre_case ()
17- child .lua (" M = require('copilot')" )
18- child .lua (" c = require('copilot.client')" )
19- child .lua (" s = require('copilot.status')" )
20- child .lua (" cmd = require('copilot.command')" )
21- child .lua (" a = require('copilot.api')" )
22- child .lua (" logger = require('copilot.logger')" )
23- child .fn .setenv (" GITHUB_COPILOT_TOKEN" , vim .NIL )
2418 end ,
2519 post_once = function ()
2620 child .stop ()
@@ -34,22 +28,59 @@ local T = MiniTest.new_set({
3428
3529T [" auth()" ] = MiniTest .new_set ()
3630
37- -- TODO: callback for this too
3831T [" auth()" ][" auth before attaching, should not give error" ] = function ()
3932 child .configure_copilot ()
4033 child .cmd (" Copilot auth" )
41- vim .loop .sleep (3000 )
42- local messages = child .cmd_capture (" messages" )
34+
35+ local messages = child .lua ([[
36+ local messages = ""
37+ local function has_passed()
38+ messages = vim.api.nvim_exec("messages", { output = true }) or ""
39+ return string.find(messages, ".*Authenticated as GitHub user.*") ~= nil
40+ end
41+
42+ vim.wait(30000, function()
43+ return has_passed()
44+ end, 50)
45+
46+ return messages
47+ ]] )
48+
4349 u .expect_match (messages , " .*Authenticated as GitHub user.*" )
4450end
4551
4652T [" auth()" ][" auth issue replication" ] = function ()
4753 child .configure_copilot ()
4854 child .cmd (" Copilot auth" )
49- vim .loop .sleep (2000 )
55+
56+ child .lua ([[
57+ local messages = ""
58+ local function has_passed()
59+ messages = vim.api.nvim_exec("messages", { output = true }) or ""
60+ return string.find(messages, ".*Authenticated as GitHub user.*") ~= nil
61+ end
62+
63+ vim.wait(30000, function()
64+ return has_passed()
65+ end, 50)
66+ ]] )
67+
5068 child .cmd (" Copilot status" )
51- vim .loop .sleep (500 )
52- local messages = child .cmd_capture (" messages" )
69+
70+ local messages = child .lua ([[
71+ local messages = ""
72+ local function has_passed()
73+ messages = vim.api.nvim_exec("messages", { output = true }) or ""
74+ return string.find(messages, ".*Online.*Enabled.*") ~= nil
75+ end
76+
77+ vim.wait(30000, function()
78+ return has_passed()
79+ end, 50)
80+
81+ return messages
82+ ]] )
83+
5384 u .expect_match (messages , " .*Online.*Enabled.*" )
5485end
5586
0 commit comments