1- run "required_variables " {
1+ run "defaults_are_correct " {
22 command = plan
33
44 variables {
5- agent_id = " test-agent-id"
6- workdir = " /home/coder"
7- external_auth_id = " github"
5+ agent_id = " test-agent"
6+ workdir = " /home/coder"
87 }
98
109 assert {
11- condition = var. agent_id == " test-agent-id "
12- error_message = " Agent ID should be set correctly "
10+ condition = var. copilot_model == " claude-sonnet-4 "
11+ error_message = " Default model should be 'claude-sonnet-4' "
1312 }
1413
1514 assert {
16- condition = var. workdir == " /home/coder "
17- error_message = " Workdir should be set correctly "
15+ condition = var. report_tasks == true
16+ error_message = " Task reporting should be enabled by default "
1817 }
1918
2019 assert {
21- condition = var. external_auth_id == " github "
22- error_message = " External auth ID should be set correctly "
20+ condition = var. resume_session == true
21+ error_message = " Session resumption should be enabled by default "
2322 }
24- }
25-
26- run "minimal_config" {
27- command = plan
2823
29- variables {
30- agent_id = " test-agent-id"
31- workdir = " /home/coder"
32- external_auth_id = " github"
24+ assert {
25+ condition = var. allow_all_tools == false
26+ error_message = " allow_all_tools should be disabled by default"
3327 }
3428
3529 assert {
3630 condition = resource. coder_env . mcp_app_status_slug . name == " CODER_MCP_APP_STATUS_SLUG"
37- error_message = " Status slug environment variable not configured correctly "
31+ error_message = " Status slug env var should be created "
3832 }
3933
4034 assert {
4135 condition = resource. coder_env . mcp_app_status_slug . value == " copilot-cli"
4236 error_message = " Status slug value should be 'copilot-cli'"
4337 }
44-
45- assert {
46- condition = var. copilot_model == " claude-sonnet-4"
47- error_message = " Default model should be 'claude-sonnet-4'"
48- }
49-
50- assert {
51- condition = var. report_tasks == true
52- error_message = " Task reporting should be enabled by default"
53- }
5438}
5539
56- run "custom_model " {
40+ run "github_token_creates_env_var " {
5741 command = plan
5842
5943 variables {
60- agent_id = " test-agent-id"
61- workdir = " /home/coder"
62- external_auth_id = " github"
63- copilot_model = " claude-sonnet-4.5"
44+ agent_id = " test-agent"
45+ workdir = " /home/coder"
46+ github_token = " test_github_token_abc123"
6447 }
6548
6649 assert {
67- condition = var . copilot_model == " claude-sonnet-4.5 "
68- error_message = " Custom model should be set correctly "
50+ condition = length (resource . coder_env . github_token ) == 1
51+ error_message = " github_token env var should be created when token is provided "
6952 }
70- }
7153
72- run "custom_copilot_config" {
73- command = plan
74-
75- variables {
76- agent_id = " test-agent-id"
77- workdir = " /home/coder"
78- external_auth_id = " github"
79- copilot_config = jsonencode ({
80- banner = " auto"
81- theme = " light"
82- trusted_folders = [" /home/coder" , " /workspace" ]
83- })
54+ assert {
55+ condition = resource. coder_env . github_token [0 ]. name == " GITHUB_TOKEN"
56+ error_message = " github_token env var name should be 'GITHUB_TOKEN'"
8457 }
8558
8659 assert {
87- condition = var . copilot_config != " "
88- error_message = " Custom copilot config should be provided "
60+ condition = resource . coder_env . github_token [ 0 ] . value == " test_github_token_abc123 "
61+ error_message = " github_token env var value should match input "
8962 }
9063}
9164
92- run "trusted_directories " {
65+ run "github_token_not_created_when_empty " {
9366 command = plan
9467
9568 variables {
96- agent_id = " test-agent-id"
97- workdir = " /home/coder"
98- external_auth_id = " github"
99- trusted_directories = [" /workspace" , " /projects" ]
69+ agent_id = " test-agent"
70+ workdir = " /home/coder"
71+ github_token = " "
10072 }
10173
10274 assert {
103- condition = length (var . trusted_directories ) == 2
104- error_message = " Trusted directories should be set correctly "
75+ condition = length (resource . coder_env . github_token ) == 0
76+ error_message = " github_token env var should not be created when empty "
10577 }
10678}
10779
108- run "mcp_config " {
80+ run "copilot_model_env_var_for_non_default " {
10981 command = plan
11082
11183 variables {
112- agent_id = " test-agent-id"
113- workdir = " /home/coder"
114- external_auth_id = " github"
115- mcp_config = jsonencode ({
116- mcpServers = {
117- custom = {
118- command = " custom-server"
119- args = [" --config" , " custom.json" ]
120- }
121- }
122- })
84+ agent_id = " test-agent"
85+ workdir = " /home/coder"
86+ copilot_model = " claude-sonnet-4.5"
12387 }
12488
12589 assert {
126- condition = var. mcp_config != " "
127- error_message = " Custom MCP config should be provided"
128- }
129- }
130-
131- run "tool_permissions" {
132- command = plan
133-
134- variables {
135- agent_id = " test-agent-id"
136- workdir = " /home/coder"
137- external_auth_id = " github"
138- allow_tools = [" fs_read" , " fs_write" ]
139- deny_tools = [" execute_bash" ]
90+ condition = length (resource. coder_env . copilot_model ) == 1
91+ error_message = " copilot_model env var should be created for non-default model"
14092 }
14193
14294 assert {
143- condition = length (var . allow_tools ) == 2
144- error_message = " Allow tools should be set correctly "
95+ condition = resource . coder_env . copilot_model [ 0 ] . name == " COPILOT_MODEL "
96+ error_message = " copilot_model env var name should be 'COPILOT_MODEL' "
14597 }
14698
14799 assert {
148- condition = length (var . deny_tools ) == 1
149- error_message = " Deny tools should be set correctly "
100+ condition = resource . coder_env . copilot_model [ 0 ] . value == " claude-sonnet-4.5 "
101+ error_message = " copilot_model env var value should match input "
150102 }
151103}
152104
153- run "ui_customization " {
105+ run "copilot_model_not_created_for_default " {
154106 command = plan
155107
156108 variables {
157- agent_id = " test-agent-id"
158- workdir = " /home/coder"
159- external_auth_id = " github"
160- order = 5
161- group = " AI Tools"
162- icon = " /icon/custom-copilot.svg"
109+ agent_id = " test-agent"
110+ workdir = " /home/coder"
111+ copilot_model = " claude-sonnet-4"
163112 }
164113
165114 assert {
166- condition = var . order == 5
167- error_message = " Order should be set correctly "
115+ condition = length (resource . coder_env . copilot_model ) == 0
116+ error_message = " copilot_model env var should not be created for default model "
168117 }
118+ }
169119
170- assert {
171- condition = var. group == " AI Tools"
172- error_message = " Group should be set correctly"
120+ run "model_validation_accepts_valid_models" {
121+ command = plan
122+
123+ variables {
124+ agent_id = " test-agent"
125+ workdir = " /home/coder"
126+ copilot_model = " gpt-5"
173127 }
174128
175129 assert {
176- condition = var . icon == " /icon/custom-copilot.svg "
177- error_message = " Icon should be set correctly "
130+ condition = contains ([ " claude-sonnet-4 " , " claude-sonnet-4.5 " , " gpt-5 " ], var . copilot_model )
131+ error_message = " Model should be one of the valid options "
178132 }
179133}
180134
181- run "install_scripts " {
135+ run "copilot_config_merges_with_trusted_directories " {
182136 command = plan
183137
184138 variables {
185- agent_id = " test-agent-id"
186- workdir = " /home/coder"
187- external_auth_id = " github"
188- pre_install_script = " echo 'Pre-install setup'"
189- post_install_script = " echo 'Post-install cleanup'"
139+ agent_id = " test-agent"
140+ workdir = " /home/coder/project"
141+ trusted_directories = [" /workspace" , " /data" ]
190142 }
191143
192144 assert {
193- condition = var . pre_install_script == " echo 'Pre-install setup' "
194- error_message = " Pre-install script should be set correctly "
145+ condition = length (local . final_copilot_config ) > 0
146+ error_message = " final_copilot_config should be computed "
195147 }
196148
149+ # Verify workdir is trimmed of trailing slash
197150 assert {
198- condition = var . post_install_script == " echo 'Post-install cleanup' "
199- error_message = " Post-install script should be set correctly "
151+ condition = local . workdir == " /home/coder/project "
152+ error_message = " workdir should be trimmed of trailing slash "
200153 }
201154}
202155
203- run "model_validation " {
156+ run "custom_copilot_config_overrides_default " {
204157 command = plan
205158
206159 variables {
207- agent_id = " test-agent-id"
208- workdir = " /home/coder"
209- external_auth_id = " github"
210- copilot_model = " gpt-5"
160+ agent_id = " test-agent"
161+ workdir = " /home/coder"
162+ copilot_config = jsonencode ({
163+ banner = " always"
164+ theme = " dark"
165+ trusted_folders = [" /custom" ]
166+ })
211167 }
212168
213169 assert {
214- condition = contains ([" claude-sonnet-4" , " claude-sonnet-4.5" , " gpt-5" ], var. copilot_model )
215- error_message = " Model should be one of the valid options"
170+ condition = var. copilot_config != " "
171+ error_message = " Custom copilot config should be set"
172+ }
173+
174+ assert {
175+ condition = local. final_copilot_config == var. copilot_config
176+ error_message = " Custom copilot config should override default"
216177 }
217178}
218179
219- run "task_reporting_disabled " {
180+ run "app_slug_is_consistent " {
220181 command = plan
221182
222183 variables {
223- agent_id = " test-agent-id"
224- workdir = " /home/coder"
225- external_auth_id = " github"
226- report_tasks = false
184+ agent_id = " test-agent"
185+ workdir = " /home/coder"
227186 }
228187
229188 assert {
230- condition = var . report_tasks == false
231- error_message = " Task reporting should be disabled when set to false "
189+ condition = local . app_slug == " copilot-cli "
190+ error_message = " app_slug should be 'copilot-cli' "
232191 }
233192
234193 assert {
235- condition = resource . coder_env . mcp_app_status_slug . name == " CODER_MCP_APP_STATUS_SLUG "
236- error_message = " Status slug should still be configured even when task reporting is disabled "
194+ condition = local . module_dir_name == " .copilot-module "
195+ error_message = " module_dir_name should be '.copilot-module' "
237196 }
238- }
197+ }
0 commit comments