@@ -1034,3 +1034,45 @@ func TestSandboxExecOutputTimeout(t *testing.T) {
10341034 g .Expect (elapsed ).To (gomega .BeNumerically (">" , 1 * time .Second ))
10351035 g .Expect (elapsed ).To (gomega .BeNumerically ("<" , 15 * time .Second ))
10361036}
1037+
1038+ func TestSandboxDoubleTerminate (t * testing.T ) {
1039+ t .Parallel ()
1040+ g := gomega .NewWithT (t )
1041+ ctx := context .Background ()
1042+ tc := newTestClient (t )
1043+
1044+ app , err := tc .Apps .FromName (ctx , "libmodal-test" , & modal.AppFromNameParams {CreateIfMissing : true })
1045+ g .Expect (err ).ToNot (gomega .HaveOccurred ())
1046+
1047+ image := tc .Images .FromRegistry ("alpine:3.21" , nil )
1048+
1049+ sb , err := tc .Sandboxes .Create (ctx , app , image , nil )
1050+ g .Expect (err ).ToNot (gomega .HaveOccurred ())
1051+
1052+ err = sb .Terminate (ctx )
1053+ g .Expect (err ).ToNot (gomega .HaveOccurred ())
1054+
1055+ err = sb .Terminate (ctx )
1056+ g .Expect (err ).ToNot (gomega .HaveOccurred ())
1057+ }
1058+
1059+ func TestSandboxExecAfterTerminate (t * testing.T ) {
1060+ t .Parallel ()
1061+ g := gomega .NewWithT (t )
1062+ ctx := context .Background ()
1063+ tc := newTestClient (t )
1064+
1065+ app , err := tc .Apps .FromName (ctx , "libmodal-test" , & modal.AppFromNameParams {CreateIfMissing : true })
1066+ g .Expect (err ).ToNot (gomega .HaveOccurred ())
1067+
1068+ image := tc .Images .FromRegistry ("alpine:3.21" , nil )
1069+
1070+ sb , err := tc .Sandboxes .Create (ctx , app , image , nil )
1071+ g .Expect (err ).ToNot (gomega .HaveOccurred ())
1072+
1073+ err = sb .Terminate (ctx )
1074+ g .Expect (err ).ToNot (gomega .HaveOccurred ())
1075+
1076+ _ , err = sb .Exec (ctx , []string {"echo" , "hello" }, nil )
1077+ g .Expect (err ).To (gomega .HaveOccurred ())
1078+ }
0 commit comments