github.com/criyle/go-sandbox@v0.10.3/pkg/forkexec/sandbox_darwin_test.go (about) 1 package forkexec 2 3 import ( 4 "os" 5 "testing" 6 ) 7 8 func TestWrite(t *testing.T) { 9 c, err := os.ReadFile("test.sb") 10 if err != nil { 11 t.Error(err) 12 return 13 } 14 15 // before load profile, it is ok 16 f, err := os.OpenFile("/tmp/sandbox_test", os.O_CREATE|os.O_RDWR, 0777) 17 if err != nil { 18 t.Error(err) 19 return 20 } 21 f.Close() 22 23 if err = SandboxLoadProfile(string(c)); err != nil { 24 t.Error(err) 25 return 26 } 27 28 // after is not ok 29 f, err = os.OpenFile("/tmp/sandbox_test", os.O_CREATE|os.O_RDWR, 0777) 30 if !os.IsPermission(err) { 31 t.Error(err) 32 return 33 } 34 f.Close() 35 }