66 testRequiredVariables ,
77} from "~test" ;
88
9+ // Use bitnami/git which has both bash and git pre-installed
10+ const gitImage = "bitnami/git" ;
11+
912describe ( "git-clone" , async ( ) => {
1013 await runTerraformInit ( import . meta. dir ) ;
1114
@@ -19,7 +22,12 @@ describe("git-clone", async () => {
1922 agent_id : "foo" ,
2023 url : "some-url" ,
2124 } ) ;
22- const output = await executeScriptInContainer ( state , "alpine" ) ;
25+ // Use debian:stable-slim which has bash but no git
26+ const output = await executeScriptInContainer (
27+ state ,
28+ "debian:stable-slim" ,
29+ "bash" ,
30+ ) ;
2331 expect ( output . exitCode ) . toBe ( 1 ) ;
2432 expect ( output . stdout ) . toEqual ( [ "Git is not installed!" ] ) ;
2533 } ) ;
@@ -29,11 +37,10 @@ describe("git-clone", async () => {
2937 agent_id : "foo" ,
3038 url : "fake-url" ,
3139 } ) ;
32- const output = await executeScriptInContainer ( state , "alpine/git" ) ;
33- expect ( output . stdout ) . toEqual ( [
34- "Creating directory ~/fake-url..." ,
35- "Cloning fake-url to ~/fake-url..." ,
36- ] ) ;
40+ const output = await executeScriptInContainer ( state , gitImage , "bash" ) ;
41+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
42+ expect ( output . stdout [ 0 ] ) . toContain ( "fake-url" ) ;
43+ expect ( output . stdout [ 1 ] ) . toContain ( "Cloning fake-url to" ) ;
3744 expect ( output . stderr . join ( " " ) ) . toContain ( "fatal" ) ;
3845 expect ( output . stderr . join ( " " ) ) . toContain ( "fake-url" ) ;
3946 } ) ;
@@ -204,25 +211,29 @@ describe("git-clone", async () => {
204211 agent_id : "foo" ,
205212 url : "https://github.com/michaelbrewer/repo-tests.log/tree/feat/branch" ,
206213 } ) ;
207- const output = await executeScriptInContainer ( state , "alpine/git ") ;
214+ const output = await executeScriptInContainer ( state , gitImage , "bash ") ;
208215 expect ( output . exitCode ) . toBe ( 0 ) ;
209- expect ( output . stdout ) . toEqual ( [
210- "Creating directory ~/repo-tests.log..." ,
211- "Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch..." ,
212- ] ) ;
216+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
217+ expect ( output . stdout [ 0 ] ) . toContain ( "repo-tests.log" ) ;
218+ expect ( output . stdout [ 1 ] ) . toContain (
219+ "Cloning https://github.com/michaelbrewer/repo-tests.log" ,
220+ ) ;
221+ expect ( output . stdout [ 1 ] ) . toContain ( "on branch feat/branch" ) ;
213222 } ) ;
214223
215224 it ( "runs with gitlab clone with switch to feat/branch" , async ( ) => {
216225 const state = await runTerraformApply ( import . meta. dir , {
217226 agent_id : "foo" ,
218227 url : "https://gitlab.com/mike.brew/repo-tests.log/-/tree/feat/branch" ,
219228 } ) ;
220- const output = await executeScriptInContainer ( state , "alpine/git ") ;
229+ const output = await executeScriptInContainer ( state , gitImage , "bash ") ;
221230 expect ( output . exitCode ) . toBe ( 0 ) ;
222- expect ( output . stdout ) . toEqual ( [
223- "Creating directory ~/repo-tests.log..." ,
224- "Cloning https://gitlab.com/mike.brew/repo-tests.log to ~/repo-tests.log on branch feat/branch..." ,
225- ] ) ;
231+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
232+ expect ( output . stdout [ 0 ] ) . toContain ( "repo-tests.log" ) ;
233+ expect ( output . stdout [ 1 ] ) . toContain (
234+ "Cloning https://gitlab.com/mike.brew/repo-tests.log" ,
235+ ) ;
236+ expect ( output . stdout [ 1 ] ) . toContain ( "on branch feat/branch" ) ;
226237 } ) ;
227238
228239 it ( "runs with github clone with branch_name set to feat/branch" , async ( ) => {
@@ -238,12 +249,14 @@ describe("git-clone", async () => {
238249 expect ( state . outputs . web_url . value ) . toEqual ( url ) ;
239250 expect ( state . outputs . branch_name . value ) . toEqual ( branch_name ) ;
240251
241- const output = await executeScriptInContainer ( state , "alpine/git ") ;
252+ const output = await executeScriptInContainer ( state , gitImage , "bash ") ;
242253 expect ( output . exitCode ) . toBe ( 0 ) ;
243- expect ( output . stdout ) . toEqual ( [
244- "Creating directory ~/repo-tests.log..." ,
245- "Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch..." ,
246- ] ) ;
254+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
255+ expect ( output . stdout [ 0 ] ) . toContain ( "repo-tests.log" ) ;
256+ expect ( output . stdout [ 1 ] ) . toContain (
257+ "Cloning https://github.com/michaelbrewer/repo-tests.log" ,
258+ ) ;
259+ expect ( output . stdout [ 1 ] ) . toContain ( "on branch feat/branch" ) ;
247260 } ) ;
248261
249262 it ( "runs post-clone script" , async ( ) => {
@@ -254,8 +267,8 @@ describe("git-clone", async () => {
254267 } ) ;
255268 const output = await executeScriptInContainer (
256269 state ,
257- "alpine/git" ,
258- "sh " ,
270+ gitImage ,
271+ "bash " ,
259272 "mkdir -p ~/fake-url && echo 'existing' > ~/fake-url/file.txt" ,
260273 ) ;
261274 expect ( output . stdout ) . toContain ( "Running post-clone script..." ) ;
@@ -268,12 +281,13 @@ describe("git-clone", async () => {
268281 url : "https://github.com/michaelbrewer/repo-tests.log" ,
269282 clone_args : "--single-branch" ,
270283 } ) ;
271- const output = await executeScriptInContainer ( state , "alpine/git ") ;
284+ const output = await executeScriptInContainer ( state , gitImage , "bash ") ;
272285 expect ( output . exitCode ) . toBe ( 0 ) ;
273- expect ( output . stdout ) . toEqual ( [
274- "Creating directory ~/repo-tests.log..." ,
275- "Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log..." ,
276- ] ) ;
286+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
287+ expect ( output . stdout [ 0 ] ) . toContain ( "repo-tests.log" ) ;
288+ expect ( output . stdout [ 1 ] ) . toContain (
289+ "Cloning https://github.com/michaelbrewer/repo-tests.log" ,
290+ ) ;
277291 } ) ;
278292
279293 it ( "runs with depth" , async ( ) => {
@@ -282,12 +296,13 @@ describe("git-clone", async () => {
282296 url : "https://github.com/michaelbrewer/repo-tests.log" ,
283297 depth : "1" ,
284298 } ) ;
285- const output = await executeScriptInContainer ( state , "alpine/git ") ;
299+ const output = await executeScriptInContainer ( state , gitImage , "bash ") ;
286300 expect ( output . exitCode ) . toBe ( 0 ) ;
287- expect ( output . stdout ) . toEqual ( [
288- "Creating directory ~/repo-tests.log..." ,
289- "Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log..." ,
290- ] ) ;
301+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
302+ expect ( output . stdout [ 0 ] ) . toContain ( "repo-tests.log" ) ;
303+ expect ( output . stdout [ 1 ] ) . toContain (
304+ "Cloning https://github.com/michaelbrewer/repo-tests.log" ,
305+ ) ;
291306 } ) ;
292307
293308 it ( "runs with depth and branch_name" , async ( ) => {
@@ -297,12 +312,14 @@ describe("git-clone", async () => {
297312 branch_name : "feat/branch" ,
298313 depth : "1" ,
299314 } ) ;
300- const output = await executeScriptInContainer ( state , "alpine/git ") ;
315+ const output = await executeScriptInContainer ( state , gitImage , "bash ") ;
301316 expect ( output . exitCode ) . toBe ( 0 ) ;
302- expect ( output . stdout ) . toEqual ( [
303- "Creating directory ~/repo-tests.log..." ,
304- "Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch..." ,
305- ] ) ;
317+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
318+ expect ( output . stdout [ 0 ] ) . toContain ( "repo-tests.log" ) ;
319+ expect ( output . stdout [ 1 ] ) . toContain (
320+ "Cloning https://github.com/michaelbrewer/repo-tests.log" ,
321+ ) ;
322+ expect ( output . stdout [ 1 ] ) . toContain ( "on branch feat/branch" ) ;
306323 } ) ;
307324
308325 it ( "runs with clone_args and branch_name" , async ( ) => {
@@ -312,12 +329,14 @@ describe("git-clone", async () => {
312329 branch_name : "feat/branch" ,
313330 clone_args : "--single-branch" ,
314331 } ) ;
315- const output = await executeScriptInContainer ( state , "alpine/git ") ;
332+ const output = await executeScriptInContainer ( state , gitImage , "bash ") ;
316333 expect ( output . exitCode ) . toBe ( 0 ) ;
317- expect ( output . stdout ) . toEqual ( [
318- "Creating directory ~/repo-tests.log..." ,
319- "Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch..." ,
320- ] ) ;
334+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
335+ expect ( output . stdout [ 0 ] ) . toContain ( "repo-tests.log" ) ;
336+ expect ( output . stdout [ 1 ] ) . toContain (
337+ "Cloning https://github.com/michaelbrewer/repo-tests.log" ,
338+ ) ;
339+ expect ( output . stdout [ 1 ] ) . toContain ( "on branch feat/branch" ) ;
321340 } ) ;
322341
323342 it ( "runs with depth, branch_name, and clone_args" , async ( ) => {
@@ -328,11 +347,13 @@ describe("git-clone", async () => {
328347 depth : "1" ,
329348 clone_args : "--single-branch" ,
330349 } ) ;
331- const output = await executeScriptInContainer ( state , "alpine/git ") ;
350+ const output = await executeScriptInContainer ( state , gitImage , "bash ") ;
332351 expect ( output . exitCode ) . toBe ( 0 ) ;
333- expect ( output . stdout ) . toEqual ( [
334- "Creating directory ~/repo-tests.log..." ,
335- "Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch..." ,
336- ] ) ;
352+ expect ( output . stdout [ 0 ] ) . toContain ( "Creating directory" ) ;
353+ expect ( output . stdout [ 0 ] ) . toContain ( "repo-tests.log" ) ;
354+ expect ( output . stdout [ 1 ] ) . toContain (
355+ "Cloning https://github.com/michaelbrewer/repo-tests.log" ,
356+ ) ;
357+ expect ( output . stdout [ 1 ] ) . toContain ( "on branch feat/branch" ) ;
337358 } ) ;
338359} ) ;
0 commit comments