-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathtest_config.lua
More file actions
108 lines (97 loc) · 2.99 KB
/
Copy pathtest_config.lua
File metadata and controls
108 lines (97 loc) · 2.99 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
local eq = MiniTest.expect.equality
local child_helper = require("tests.child_helper")
local child = child_helper.new_child_neovim("test_config")
local T = MiniTest.new_set({
hooks = {
pre_once = function() end,
pre_case = function()
child.run_pre_case(true)
end,
post_once = child.stop,
},
})
T["config()"] = MiniTest.new_set()
T["config()"]["validate accepts valid config with defaults"] = function()
local result = child.lua([[
local config = require("copilot.config")
local ok = pcall(config.validate, config)
return ok
]])
eq(result, true)
end
T["config()"]["validate rejects invalid panel type"] = function()
local result = child.lua([[
local config = require("copilot.config")
local bad_config = vim.tbl_deep_extend("force", {}, config)
bad_config.panel = "not a table"
local ok = pcall(config.validate, bad_config)
return ok
]])
eq(result, false)
end
T["config()"]["validate rejects invalid suggestion type"] = function()
local result = child.lua([[
local config = require("copilot.config")
local bad_config = vim.tbl_deep_extend("force", {}, config)
bad_config.suggestion = 42
local ok = pcall(config.validate, bad_config)
return ok
]])
eq(result, false)
end
T["config()"]["merge_with_user_configs applies user overrides"] = function()
local result = child.lua([[
local config = require("copilot.config")
config.merge_with_user_configs({
copilot_model = "gpt-4o",
filetypes = { python = true },
})
return { model = config.copilot_model, python = config.filetypes.python }
]])
eq(result.model, "gpt-4o")
eq(result.python, true)
end
T["config()"]["merge_with_user_configs preserves defaults for unspecified fields"] = function()
local result = child.lua([[
local config = require("copilot.config")
config.merge_with_user_configs({})
return {
node_cmd = config.copilot_node_command,
disable_limit = config.disable_limit_reached_message,
}
]])
eq(result.node_cmd, "node")
eq(result.disable_limit, false)
end
T["config()"]["copilot_node_command accepts string"] = function()
local result = child.lua([[
local config = require("copilot.config")
config.merge_with_user_configs({
copilot_node_command = "/usr/local/bin/node",
})
return config.copilot_node_command
]])
eq(result, "/usr/local/bin/node")
end
T["config()"]["copilot_node_command accepts table"] = function()
local result = child.lua([[
local config = require("copilot.config")
config.merge_with_user_configs({
copilot_node_command = { "mise", "x", "node@lts", "--", "node" },
})
return config.copilot_node_command
]])
eq(type(result), "table")
eq(result[1], "mise")
end
T["config()"]["root_dir accepts string"] = function()
local result = child.lua([[
local config = require("copilot.config")
config.merge_with_user_configs({
root_dir = "/home/user/project",
})
return config.root_dir
]])
eq(result, "/home/user/project")
end
return T