Skip to content

Commit 324840a

Browse files
committed
add tftest.hcl file
1 parent cab83b0 commit 324840a

File tree

2 files changed

+168
-35
lines changed

2 files changed

+168
-35
lines changed

registry/coder/modules/aider/main.test.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -135,39 +135,4 @@ describe("Aider", async () => {
135135
);
136136
expect(postLog).toContain("post-install-script");
137137
});
138-
139-
test("system-prompt", async () => {
140-
const system_prompt = "this is a system prompt for Aider";
141-
const { id } = await setup({
142-
moduleVariables: {
143-
system_prompt,
144-
model: "gemini",
145-
},
146-
});
147-
await execModuleScript(id);
148-
const resp = await readFileContainer(
149-
id,
150-
"/home/coder/.aider-module/SYSTEM_PROMPT.md",
151-
);
152-
expect(resp).toContain(system_prompt);
153-
});
154-
155-
test("task-prompt", async () => {
156-
const prompt = "this is a task prompt for Aider";
157-
const apiKey = "test-api-key-123";
158-
const { id } = await setup({
159-
moduleVariables: {
160-
credentials: apiKey,
161-
model: "gemini",
162-
},
163-
});
164-
await execModuleScript(id, {
165-
ARG_AI_PROMPT: `${prompt}`,
166-
});
167-
const resp = await readFileContainer(
168-
id,
169-
"/home/coder/.aider-module/agentapi-start.log",
170-
);
171-
expect(resp).toContain(`Aider task prompt provided : ${prompt}`);
172-
});
173138
});
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
run "test_aider_basic" {
2+
command = plan
3+
4+
variables {
5+
agent_id = "test-agent-123"
6+
workdir = "/home/coder"
7+
}
8+
9+
assert {
10+
condition = var.workdir == "/home/coder"
11+
error_message = "Workdir variable should default to /home/coder"
12+
}
13+
14+
assert {
15+
condition = var.agent_id == "test-agent-123"
16+
error_message = "Agent ID variable should be set correctly"
17+
}
18+
19+
assert {
20+
condition = var.install_aider == true
21+
error_message = "install_aider should default to true"
22+
}
23+
24+
assert {
25+
condition = var.install_agentapi == true
26+
error_message = "install_agentapi should default to true"
27+
}
28+
29+
assert {
30+
condition = var.report_tasks == false
31+
error_message = "report_tasks should default to false"
32+
}
33+
}
34+
35+
run "test_with_credentials" {
36+
command = plan
37+
38+
variables {
39+
agent_id = "test-agent-456"
40+
workdir = "/home/coder/workspace"
41+
credentials = "test-api-key-123"
42+
}
43+
44+
assert {
45+
condition = var.credentials == "test-api-key-123"
46+
error_message = "Credentials value should match the input"
47+
}
48+
}
49+
50+
run "test_custom_options" {
51+
command = plan
52+
53+
variables {
54+
agent_id = "test-agent-789"
55+
workdir = "/home/coder/custom"
56+
order = 5
57+
group = "development"
58+
icon = "/icon/custom.svg"
59+
model = "4o"
60+
ai_prompt = "Help me write better code"
61+
install_aider = false
62+
install_agentapi = false
63+
agentapi_version = "v0.6.3"
64+
credentials = ""
65+
base_aider_config = "read:\n - CONVENTIONS.md"
66+
}
67+
68+
assert {
69+
condition = var.order == 5
70+
error_message = "Order variable should be set to 5"
71+
}
72+
73+
assert {
74+
condition = var.group == "development"
75+
error_message = "Group variable should be set to 'development'"
76+
}
77+
78+
assert {
79+
condition = var.icon == "/icon/custom.svg"
80+
error_message = "Icon variable should be set to custom icon"
81+
}
82+
83+
assert {
84+
condition = var.model == "4o"
85+
error_message = "Model variable should be set to '4o'"
86+
}
87+
88+
assert {
89+
condition = var.ai_prompt == "Help me write better code"
90+
error_message = "AI prompt variable should be set correctly"
91+
}
92+
93+
assert {
94+
condition = var.install_aider == false
95+
error_message = "install_aider should be set to false"
96+
}
97+
98+
assert {
99+
condition = var.install_agentapi == false
100+
error_message = "install_agentapi should be set to false"
101+
}
102+
103+
assert {
104+
condition = var.agentapi_version == "v0.6.3"
105+
error_message = "AgentAPI version should be set to 'v0.6.3'"
106+
}
107+
}
108+
109+
run "test_with_scripts" {
110+
command = plan
111+
112+
variables {
113+
agent_id = "test-agent-scripts"
114+
workdir = "/home/coder/scripts"
115+
pre_install_script = "echo 'Pre-install script'"
116+
post_install_script = "echo 'Post-install script'"
117+
}
118+
119+
assert {
120+
condition = var.pre_install_script == "echo 'Pre-install script'"
121+
error_message = "Pre-install script should be set correctly"
122+
}
123+
124+
assert {
125+
condition = var.post_install_script == "echo 'Post-install script'"
126+
error_message = "Post-install script should be set correctly"
127+
}
128+
}
129+
130+
run "test_ai_provider_env_mapping" {
131+
command = plan
132+
133+
variables {
134+
agent_id = "test-agent-provider"
135+
workdir = "/home/coder/test"
136+
ai_provider = "google"
137+
custom_env_var_name = ""
138+
}
139+
140+
# Ensure provider -> env var mapping works as expected (based on locals.provider_env_vars)
141+
assert {
142+
condition = var.ai_provider == "google"
143+
error_message = "AI provider should be set to 'google' for this test"
144+
}
145+
}
146+
147+
run "test_system_prompt_wrapping" {
148+
command = plan
149+
150+
variables {
151+
agent_id = "test-agent-system-prompt"
152+
workdir = "/home/coder/test"
153+
system_prompt = "Custom addition"
154+
report_tasks = true
155+
}
156+
157+
assert {
158+
condition = var.system_prompt == "Custom addition"
159+
error_message = "System prompt variable should be set correctly"
160+
}
161+
162+
# When report_tasks is true, the module builds a final_system_prompt local that includes the Task Reporting section.
163+
# We can't directly reference locals from here reliably, so just assert report_tasks is true for this run.
164+
assert {
165+
condition = var.report_tasks == true
166+
error_message = "report_tasks should be true for this test"
167+
}
168+
}

0 commit comments

Comments
 (0)