package cli import ( "os" "path/filepath" "testing" "github.com/Nwflower/reims-go/internal/driver" ) func TestExplicitCurrentDataRootCanHandoff(t *testing.T) { root := t.TempDir() t.Setenv("REIMS_GO_DATA_ROOT", root) if !canHandoffDataRoot(root) || !canHandoffDataRoot(filepath.Join(root, ".")) { t.Fatal("显式指定相同数据目录不应绕过管理器") } other := filepath.Join(root, "other") if err := os.Mkdir(other, 0700); err != nil { t.Fatal(err) } if canHandoffDataRoot(other) { t.Fatal("不应将其他数据目录交给当前管理器") } } func TestDirectBridgeStartAndResumeAreRejected(t *testing.T) { for _, mode := range []string{"bridge", "nat", "off"} { err := requireDirectNetwork(driver.VMInfo{DriverID: driver.BuiltinReimsMacOSDriverID, DriverData: map[string]any{"network_mode": mode}}) if (err != nil) != (mode == "bridge") { t.Errorf("直接启动 %s: %v", mode, err) } } if err := requireDirectNetwork(driver.VMInfo{DriverID: "example.other", DriverData: map[string]any{"network_mode": "bridge"}}); err != nil { t.Fatalf("不应限制其他驱动自己的桥接实现: %v", err) } }