@@ -159,6 +159,12 @@ describe("archive", () => {
159
159
160
160
const { id } = await installArchive ( state ) ;
161
161
162
+ const createTestdata = await bashRun (
163
+ id ,
164
+ `mkdir ~/gzip; touch ~/gzip/defaults.txt` ,
165
+ ) ;
166
+ ensureRunOk ( "create testdata" , createTestdata ) ;
167
+
162
168
const run = await bashRun ( id , `${ BIN_DIR } /coder-archive-create` ) ;
163
169
ensureRunOk ( "archive-create default run" , run ) ;
164
170
@@ -172,35 +178,39 @@ describe("archive", () => {
172
178
173
179
const list = await listTar ( id , "/tmp/coder-archive.tar.gz" ) ;
174
180
ensureRunOk ( "list default archive" , list ) ;
175
-
176
- // We don't assert specific entries to avoid environment coupling.
177
- expect ( list . stdout . length ) . toBeGreaterThan ( 0 ) ;
181
+ expect ( list . stdout ) . toContain ( "gzip/defaults.txt" ) ;
178
182
} , 20000 ) ;
179
183
180
184
it ( "creates a gzip archive with explicit -f and includes extra CLI paths" , async ( ) => {
181
185
const state = await runTerraformApply ( import . meta. dir , {
182
186
agent_id : "agent-123" ,
183
187
// Provide a simple default path so we can assert contents.
184
- paths : `["/etc/hostname "]` ,
188
+ paths : `["~/gzip "]` ,
185
189
compression : "gzip" ,
186
190
} ) ;
187
191
188
192
const { id } = await installArchive ( state ) ;
189
193
194
+ const createTestdata = await bashRun (
195
+ id ,
196
+ `mkdir ~/gzip; touch ~/gzip/test.txt; touch ~/gziptest.txt` ,
197
+ ) ;
198
+ ensureRunOk ( "create testdata" , createTestdata ) ;
199
+
190
200
const out = "/tmp/backup/test-archive.tar.gz" ;
191
201
const run = await bashRun (
192
202
id ,
193
- `${ BIN_DIR } /coder-archive-create -f ${ out } /etc/hosts ` ,
203
+ `${ BIN_DIR } /coder-archive-create -f ${ out } ~/gziptest.txt ` ,
194
204
) ;
195
205
ensureRunOk ( "archive-create gzip explicit -f" , run ) ;
196
206
197
207
expect ( run . stdout . trim ( ) ) . toEqual ( out ) ;
198
208
expect ( await fileExists ( id , out ) ) . toBe ( true ) ;
199
209
200
- const tarList = await sh ( id , `tar -tzf ${ out } ` ) ;
201
- ensureRunOk ( "tar -tzf contents (gzip)" , tarList ) ;
202
- expect ( tarList . stdout ) . toContain ( "etc/hosts " ) ;
203
- expect ( tarList . stdout ) . toContain ( "etc/hostname " ) ;
210
+ const list = await sh ( id , `tar -tzf ${ out } ` ) ;
211
+ ensureRunOk ( "tar -tzf contents (gzip)" , list ) ;
212
+ expect ( list . stdout ) . toContain ( "gzip/test.txt " ) ;
213
+ expect ( list . stdout ) . toContain ( "gziptest.txt " ) ;
204
214
} , 20000 ) ;
205
215
206
216
it ( "creates a zstd-compressed archive when requested via CLI override" , async ( ) => {
0 commit comments