forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_client.lua
More file actions
73 lines (65 loc) · 2.34 KB
/
test_client.lua
File metadata and controls
73 lines (65 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
local child = MiniTest.new_child_neovim()
local u = require("tests.utils")
local env = require("tests.env")
local T = MiniTest.new_set({
hooks = {
pre_once = function()
if vim.fn.filereadable("./tests/logs/test_client.log") == 1 then
vim.fn.delete("./tests/logs/test_client.log")
end
end,
pre_case = function()
child.restart({ "-u", "tests/scripts/minimal_init.lua" })
child.lua([[M = require('copilot')]])
child.lua([[c = require('copilot.client')]])
child.lua([[s = require('copilot.status')]])
child.lua([[cmd = require('copilot.command')]])
child.lua([[a = require('copilot.api')]])
child.lua("logger = require('copilot.logger')")
-- child.lua([[require("osv").launch({ port = 8086 })]])
child.fn.setenv("GITHUB_COPILOT_TOKEN", env.COPILOT_TOKEN)
end,
post_once = child.stop,
},
})
T["client.config()"] = MiniTest.new_set()
T["client.config()"]["config, github-enterprise populated"] = function()
child.lua([[M.setup({
auth_provider_url = "https://someurl.com",
})]])
local settings = child.lua([[return vim.inspect(c.config.settings)]])
u.expect_match(settings, "{.*github%-enterprise.*{.*uri.*https://someurl%.com.*}.*}")
end
T["client()"] = MiniTest.new_set()
-- T["client()"]["buf_attach"] = function()
-- child.lua([[M.setup({
-- logger = {
-- file_log_level = vim.log.levels.TRACE,
-- file = "./tests/logs/test_client.log",
-- },
-- })]])
--
-- child.lua([[cmd.enable()]])
-- child.lua([[cmd.attach({ force = true })]])
-- local messages = child.cmd_capture("messages")
-- vim.loop.sleep(500)
-- -- u.expect_match(messages, "Copilot: Copilot attached to buffer")
-- print(messages)
-- end
-- TODO: The sleep is a poor way to wait for the scheduled job to be done...
-- have not found a better way yet.
T["client()"]["status info"] = function()
child.lua([[M.setup({
logger = {
file_log_level = vim.log.levels.TRACE,
file = "./tests/logs/test_client.log",
},
})]])
-- child.lua("vim.wait(0)") -- does not seem to be enough to force the async job
vim.loop.sleep(500)
child.cmd("Copilot status")
vim.loop.sleep(500)
local messages = child.cmd_capture("messages")
u.expect_match(messages, ".*Online.*Enabled.*")
end
return T