Skip to content

Commit cf77c8a

Browse files
committed
add test
1 parent 8f079ed commit cf77c8a

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

registry/coder/modules/jfrog-oauth/main.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,38 @@ EOF`;
150150
'if [ -z "YES" ]; then\n not_configured conda',
151151
);
152152
});
153+
it("generates a maven settings.xml with multiple repos", async () => {
154+
const state = await runTerraformApply<TestVariables>(import.meta.dir, {
155+
agent_id: "some-agent-id",
156+
jfrog_url: fakeFrogUrl,
157+
package_managers: JSON.stringify({
158+
maven: ["central", "snapshots", "local"],
159+
}),
160+
});
161+
162+
const coderScript = findResourceInstance(state, "coder_script");
163+
164+
expect(coderScript.script).toContain(
165+
'jf mvnc --global --repo-resolve "central"',
166+
);
167+
168+
expect(coderScript.script).toContain("<servers>");
169+
expect(coderScript.script).toContain("<id>central</id>");
170+
expect(coderScript.script).toContain("<id>snapshots</id>");
171+
expect(coderScript.script).toContain("<id>local</id>");
172+
173+
expect(coderScript.script).toContain(
174+
"<url>http://localhost:8081/artifactory/central</url>",
175+
);
176+
expect(coderScript.script).toContain(
177+
"<url>http://localhost:8081/artifactory/snapshots</url>",
178+
);
179+
expect(coderScript.script).toContain(
180+
"<url>http://localhost:8081/artifactory/local</url>",
181+
);
182+
183+
expect(coderScript.script).toContain(
184+
'if [ -z "YES" ]; then\n not_configured maven',
185+
);
186+
});
153187
});

registry/coder/modules/jfrog-token/main.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,39 @@ EOF`;
187187
'if [ -z "YES" ]; then\n not_configured conda',
188188
);
189189
});
190+
it("generates a maven settings.xml with multiple repos", async () => {
191+
const state = await runTerraformApply<TestVariables>(import.meta.dir, {
192+
agent_id: "some-agent-id",
193+
jfrog_url: fakeFrogUrl,
194+
artifactory_access_token: "XXXX",
195+
package_managers: JSON.stringify({
196+
maven: ["central", "snapshots", "local"],
197+
}),
198+
});
199+
200+
const coderScript = findResourceInstance(state, "coder_script");
201+
202+
expect(coderScript.script).toContain(
203+
'jf mvnc --global --repo-resolve "central"',
204+
);
205+
206+
expect(coderScript.script).toContain("<servers>");
207+
expect(coderScript.script).toContain("<id>central</id>");
208+
expect(coderScript.script).toContain("<id>snapshots</id>");
209+
expect(coderScript.script).toContain("<id>local</id>");
210+
211+
expect(coderScript.script).toContain(
212+
`<url>${fakeFrogUrl}/artifactory/central</url>`,
213+
);
214+
expect(coderScript.script).toContain(
215+
`<url>${fakeFrogUrl}/artifactory/snapshots</url>`,
216+
);
217+
expect(coderScript.script).toContain(
218+
`<url>${fakeFrogUrl}/artifactory/local</url>`,
219+
);
220+
221+
expect(coderScript.script).toContain(
222+
'if [ -z "YES" ]; then\n not_configured maven',
223+
);
224+
});
190225
});

0 commit comments

Comments
 (0)