@@ -25,11 +25,15 @@ const installScriptInContainer = async (
2525 "mkdir -p /tmp/coder-script-data/bin /tmp/coder-script-data" ,
2626 ] ) ;
2727
28- await execContainer ( id , [ "sh" , "-c" , "apk add --no-cache tar gzip zstd" ] ) ;
28+ await execContainer ( id , [
29+ "sh" ,
30+ "-c" ,
31+ "apk add --no-cache bash tar gzip zstd" ,
32+ ] ) ;
2933
3034 const resp = await execContainer (
3135 id ,
32- [ "sh " , "-c" , instance . script ] ,
36+ [ "bash " , "-c" , instance . script ] ,
3337 [
3438 "--env" ,
3539 "CODER_SCRIPT_BIN_DIR=/tmp/coder-script-data/bin" ,
@@ -40,10 +44,12 @@ const installScriptInContainer = async (
4044 ) ;
4145
4246 const stdout = resp . stdout . trim ( ) . split ( "\n" ) ;
47+ const stderr = resp . stderr . trim ( ) . split ( "\n" ) ;
4348 return {
4449 id,
4550 exitCode : resp . exitCode ,
4651 stdout,
52+ stderr,
4753 } ;
4854} ;
4955
@@ -66,9 +72,11 @@ describe("archive", async () => {
6672 ) ;
6773 const result = await installScriptInContainer ( state , "alpine" ) ;
6874 expect ( result . exitCode ) . toBe ( 0 ) ;
69- expect ( result . stdout [ result . stdout . length - 1 ] ) . toEqual (
70- "Installed extract script to: /tmp/coder-script-data/bin/coder-archive-create" ,
71- ) ;
75+ expect ( result . stdout ) . toEqual ( [
76+ "Installed archive library to: /tmp/coder-script-data/archive-lib.sh" ,
77+ "Installed create script to: /tmp/coder-script-data/bin/coder-archive-create" ,
78+ "Installed extract script to: /tmp/coder-script-data/bin/coder-archive-extract" ,
79+ ] ) ;
7280
7381 // Verify the script is executable
7482 const execCheck = await execContainer ( result . id , [
@@ -79,33 +87,26 @@ describe("archive", async () => {
7987 expect ( execCheck . stdout . trim ( ) ) . toEqual ( "ok" ) ;
8088 } ) ;
8189
82- return ;
83-
8490 it ( "creates a gzip archive and prints the archive path" , async ( ) => {
8591 const state = await runTerraformApply ( import . meta. dir , {
8692 agent_id : "agent-123" ,
93+ directory : "$HOME" ,
8794 paths : `["/etc/hostname"]` ,
8895 compression : "gzip" ,
8996 } ) ;
9097
91- expect ( state . outputs . archive_path . value ) . toEqual ( "" ) ;
9298 const result = await installScriptInContainer ( state , "alpine" ) ;
9399
94- // Install bash to run the script
95- await execContainer ( result . id , [ "sh" , "-c" , "apk add --no-cache bash" ] ) ;
96-
97100 // Run the archiver with explicit name and output dir
98101 const run = await execContainer ( result . id , [
99102 "sh" ,
100103 "-c" ,
101- "/bin/bash / tmp/coder-script-data/bin/coder-archive-create -n test-archive -o /tmp/backup /etc/hosts" ,
104+ "/tmp/coder-script-data/bin/coder-archive-create -f /tmp/backup/test-archive.tar.gz /etc/hosts" ,
102105 ] ) ;
103106
104- const out = run . stdout . trim ( ) . split ( "\n" ) . filter ( Boolean ) ;
105107 expect ( run . exitCode ) . toBe ( 0 ) ;
106- // Only the archive path should be printed to stdout
107- expect ( out . length ) . toBe ( 1 ) ;
108- expect ( out [ 0 ] ) . toEqual ( "/tmp/backup/test-archive.tar.gz" ) ;
108+ // Only the archive path should be printed to stdout.
109+ expect ( run . stdout . trim ( ) ) . toEqual ( "/tmp/backup/test-archive.tar.gz" ) ;
109110
110111 // Validate file exists and is a valid gzip tar
111112 const exists = await execContainer ( result . id , [
@@ -123,6 +124,8 @@ describe("archive", async () => {
123124 expect ( tarList . exitCode ) . toBe ( 0 ) ;
124125 } , 20000 ) ;
125126
127+ return ;
128+
126129 it ( "creates a zstd-compressed archive when requested" , async ( ) => {
127130 const state = await runTerraformApply ( import . meta. dir , {
128131 agent_id : "agent-123" ,
0 commit comments