@@ -11,23 +11,6 @@ const sandbox = async (...args: string[]) => {
1111 return await $ . raw `deno sandbox ${ args . join ( " " ) } ` . text ( ) ;
1212} ;
1313
14- Deno . test ( "volumes create" , async ( ) => {
15- const volumeName = `test-vol-${ crypto . randomUUID ( ) } ` . slice ( 0 , 32 ) ;
16-
17- const volumeId = await sandbox (
18- "volumes" ,
19- "create" ,
20- volumeName ,
21- "--capacity" ,
22- "1gb" ,
23- "--region" ,
24- "ord" ,
25- ) ;
26- assertExists ( volumeId . trim ( ) ) ;
27-
28- await sandbox ( "volumes" , "delete" , volumeId . trim ( ) ) ;
29- } ) ;
30-
3114Deno . test ( "sandbox create" , async ( ) => {
3215 const sandboxId = await sandbox (
3316 "create" ,
@@ -85,6 +68,62 @@ Deno.test("sandbox extend", async () => {
8568 await sandbox ( "kill" , cleanId ) ;
8669} ) ;
8770
71+ Deno . test ( "sandbox exec with complex commands" , async ( ) => {
72+ const sandboxId = await sandbox ( "create" , "--quiet" , "--lifetime" , "60s" ) ;
73+ const cleanId = sandboxId . trim ( ) ;
74+
75+ const result = await sandbox ( "exec" , cleanId , "'echo hello && echo world'" ) ;
76+ assertEquals ( result . includes ( "hello" ) , true ) ;
77+ assertEquals ( result . includes ( "world" ) , true ) ;
78+
79+ await sandbox ( "kill" , cleanId ) ;
80+ } ) ;
81+
82+ Deno . test ( "sandbox copy directory structure" , async ( ) => {
83+ const sandboxId = await sandbox ( "create" , "--quiet" , "--lifetime" , "60s" ) ;
84+ const cleanId = sandboxId . trim ( ) ;
85+
86+ await Deno . mkdir ( "testdir" , { recursive : true } ) ;
87+ await Deno . writeTextFile ( "testdir/file1.txt" , "content1" ) ;
88+ await Deno . writeTextFile ( "testdir/file2.txt" , "content2" ) ;
89+
90+ await sandbox ( "exec" , cleanId , "'mkdir -p /tmp/testdir'" ) ;
91+ await sandbox (
92+ "copy" ,
93+ "testdir/file1.txt" ,
94+ `${ cleanId } :/tmp/testdir/file1.txt` ,
95+ ) ;
96+ await sandbox (
97+ "copy" ,
98+ "testdir/file2.txt" ,
99+ `${ cleanId } :/tmp/testdir/file2.txt` ,
100+ ) ;
101+
102+ const result = await sandbox ( "exec" , cleanId , "ls" , "/tmp/testdir" ) ;
103+ assertEquals ( result . includes ( "file1.txt" ) , true ) ;
104+ assertEquals ( result . includes ( "file2.txt" ) , true ) ;
105+
106+ await Deno . remove ( "testdir" , { recursive : true } ) ;
107+ await sandbox ( "kill" , cleanId ) ;
108+ } ) ;
109+
110+ Deno . test ( "volumes create" , async ( ) => {
111+ const volumeName = `test-vol-${ crypto . randomUUID ( ) } ` . slice ( 0 , 32 ) ;
112+
113+ const volumeId = await sandbox (
114+ "volumes" ,
115+ "create" ,
116+ volumeName ,
117+ "--capacity" ,
118+ "1gb" ,
119+ "--region" ,
120+ "ord" ,
121+ ) ;
122+ assertExists ( volumeId . trim ( ) ) ;
123+
124+ await sandbox ( "volumes" , "delete" , volumeId . trim ( ) ) ;
125+ } ) ;
126+
88127Deno . test ( "sandbox with volume mount" , async ( ) => {
89128 const volumeName = `test-vol-${ crypto . randomUUID ( ) } ` . slice ( 0 , 32 ) ;
90129
@@ -125,42 +164,3 @@ Deno.test("sandbox with volume mount", async () => {
125164 await sandbox ( "kill" , cleanId ) ;
126165 await sandbox ( "volumes" , "delete" , cleanVolumeId ) ;
127166} ) ;
128-
129- Deno . test ( "sandbox exec with complex commands" , async ( ) => {
130- const sandboxId = await sandbox ( "create" , "--quiet" , "--lifetime" , "60s" ) ;
131- const cleanId = sandboxId . trim ( ) ;
132-
133- const result = await sandbox ( "exec" , cleanId , "'echo hello && echo world'" ) ;
134- assertEquals ( result . includes ( "hello" ) , true ) ;
135- assertEquals ( result . includes ( "world" ) , true ) ;
136-
137- await sandbox ( "kill" , cleanId ) ;
138- } ) ;
139-
140- Deno . test ( "sandbox copy directory structure" , async ( ) => {
141- const sandboxId = await sandbox ( "create" , "--quiet" , "--lifetime" , "60s" ) ;
142- const cleanId = sandboxId . trim ( ) ;
143-
144- await Deno . mkdir ( "testdir" , { recursive : true } ) ;
145- await Deno . writeTextFile ( "testdir/file1.txt" , "content1" ) ;
146- await Deno . writeTextFile ( "testdir/file2.txt" , "content2" ) ;
147-
148- await sandbox ( "exec" , cleanId , "'mkdir -p /tmp/testdir'" ) ;
149- await sandbox (
150- "copy" ,
151- "testdir/file1.txt" ,
152- `${ cleanId } :/tmp/testdir/file1.txt` ,
153- ) ;
154- await sandbox (
155- "copy" ,
156- "testdir/file2.txt" ,
157- `${ cleanId } :/tmp/testdir/file2.txt` ,
158- ) ;
159-
160- const result = await sandbox ( "exec" , cleanId , "ls" , "/tmp/testdir" ) ;
161- assertEquals ( result . includes ( "file1.txt" ) , true ) ;
162- assertEquals ( result . includes ( "file2.txt" ) , true ) ;
163-
164- await Deno . remove ( "testdir" , { recursive : true } ) ;
165- await sandbox ( "kill" , cleanId ) ;
166- } ) ;
0 commit comments