返回 DeepSeek-Reasonix
session_temp_env_test.go
根目录 / internal / sandbox / session_temp_env_test.go
1 package sandbox
2
3 import (
4 "runtime"
5 "strings"
6 "testing"
7 )
8
9 func TestSessionTempEnvLinuxSandboxedPointsAtVirtualTmp(t *testing.T) {
10 if runtime.GOOS != "linux" {
11 t.Skip("linux sandbox mapping only")
12 }
13 env := SessionTempEnv("/private/session-tmp", true)
14 for _, kv := range env {
15 if !strings.HasSuffix(kv, "=/tmp") {
16 t.Fatalf("linux sandboxed env %q should point at /tmp", kv)
17 }
18 }
19 }
20
21 func TestSessionTempEnvHostPrivate(t *testing.T) {
22 dir := "/tmp/reasonix-session-tmp-test"
23 env := SessionTempEnv(dir, false)
24 if len(env) != 3 {
25 t.Fatalf("env count = %d, want 3", len(env))
26 }
27 m := SessionTempEnvMap(dir, false)
28 for _, key := range SessionTempEnvKeys {
29 if m[key] != dir {
30 t.Fatalf("%s = %q, want %q", key, m[key], dir)
31 }
32 }
33 }
34
35 func TestSessionTempEnvEmpty(t *testing.T) {
36 if SessionTempEnv("", true) != nil {
37 t.Fatal("empty session temp must not emit overrides")
38 }
39 if SessionTempEnvMap("", false) != nil {
40 t.Fatal("empty session temp map must be nil")
41 }
42 }
43
43 lines GO