@@ -2,9 +2,10 @@ local child_helper = require("tests.child_helper")
2
2
local child = child_helper .new_child_neovim (" test_auth" )
3
3
local u = require (" tests.utils" )
4
4
5
- local config_path = require (" copilot.auth" ).find_config_path ()
5
+ local config_path = require (" copilot.auth" ).find_config_path () .. " /github-copilot "
6
6
local config_path_renamed = config_path .. " _temp_renamed"
7
7
8
+ -- TODO: find a way to not mess with folders
8
9
local T = MiniTest .new_set ({
9
10
hooks = {
10
11
pre_once = function ()
@@ -14,13 +15,6 @@ local T = MiniTest.new_set({
14
15
end ,
15
16
pre_case = function ()
16
17
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 )
24
18
end ,
25
19
post_once = function ()
26
20
child .stop ()
@@ -34,22 +28,59 @@ local T = MiniTest.new_set({
34
28
35
29
T [" auth()" ] = MiniTest .new_set ()
36
30
37
- -- TODO: callback for this too
38
31
T [" auth()" ][" auth before attaching, should not give error" ] = function ()
39
32
child .configure_copilot ()
40
33
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
+
43
49
u .expect_match (messages , " .*Authenticated as GitHub user.*" )
44
50
end
45
51
46
52
T [" auth()" ][" auth issue replication" ] = function ()
47
53
child .configure_copilot ()
48
54
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
+
50
68
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
+
53
84
u .expect_match (messages , " .*Online.*Enabled.*" )
54
85
end
55
86
0 commit comments