@@ -4,8 +4,7 @@ package e2e
44
55import (
66 "context"
7- "fmt"
8- "testing"
7+ "testing"
98)
109
1110func TestLifecycle (t * testing.T ) {
@@ -60,22 +59,8 @@ func TestLifecycle(t *testing.T) {
6059 t .Errorf ("pause: expected status 'paused', got %q" , paused .Status )
6160 }
6261
63- // Step 5: Resume — command polls internally and renders JSON when not on TTY.
64- resumeCtx , resumeCancel := context .WithTimeout (context .Background (), createTimeout )
65- defer resumeCancel ()
66- resumeOut , resumeErr , resumeCode := runCLICtx (resumeCtx , "sandbox" , "resume" , sb .ID )
67- if resumeCode != 0 {
68- t .Fatalf ("sandbox resume failed (exit %d)\n stdout: %s\n stderr: %s" , resumeCode , resumeOut , resumeErr )
69- }
70- resumed := mustJSON [SandboxView ](t , resumeOut )
71- if resumed .Status != "running" {
72- t .Errorf ("resume: expected status 'running', got %q" , resumed .Status )
73- }
74-
75- // Step 6: Fork — command polls until running (default) and renders JSON.
62+ // Step 5: Fork — API requires source to be paused; fork auto-resumes.
7663 // Note: sandbox/fork does not expose a --name flag; the server assigns a name.
77- forkName := fmt .Sprintf ("e2e-%s-fork" , runID )
78- _ = forkName // no --name flag; kept for tracing only
7964 forkCtx , forkCancel := context .WithTimeout (context .Background (), createTimeout )
8065 defer forkCancel ()
8166 forkOut , forkErr , forkCode := runCLICtx (forkCtx , "sandbox" , "fork" , sb .ID )
@@ -86,13 +71,23 @@ func TestLifecycle(t *testing.T) {
8671 if forked .ID == sb .ID {
8772 t .Errorf ("fork: expected new sandbox ID, got same ID %q" , forked .ID )
8873 }
89- // Register cleanup for the forked sandbox.
9074 t .Cleanup (func () {
91- runCLI ("sandbox" , "rm" , "--force" , forked .ID ) //nolint:errcheck
75+ _ , _ , _ = runCLI ("sandbox" , "rm" , "--force" , forked .ID )
9276 })
93- // Fork auto-resumes by default; wait to confirm it is running.
9477 waitRunning (t , forked .ID )
9578
79+ // Step 6: Resume source sandbox.
80+ resumeCtx , resumeCancel := context .WithTimeout (context .Background (), createTimeout )
81+ defer resumeCancel ()
82+ resumeOut , resumeErr , resumeCode := runCLICtx (resumeCtx , "sandbox" , "resume" , sb .ID )
83+ if resumeCode != 0 {
84+ t .Fatalf ("sandbox resume failed (exit %d)\n stdout: %s\n stderr: %s" , resumeCode , resumeOut , resumeErr )
85+ }
86+ resumed := mustJSON [SandboxView ](t , resumeOut )
87+ if resumed .Status != "running" {
88+ t .Errorf ("resume: expected status 'running', got %q" , resumed .Status )
89+ }
90+
9691 // Step 7: Rm — explicitly delete the original sandbox.
9792 rmCtx , rmCancel := context .WithTimeout (context .Background (), defaultTimeout )
9893 defer rmCancel ()
0 commit comments