42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package macosdriver
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/Nwflower/reims-go/internal/config"
|
|
"github.com/Nwflower/reims-go/internal/driver"
|
|
)
|
|
|
|
func TestReimsMacOSDriverValidateCreateRejectsLeftoverDir(t *testing.T) {
|
|
cfg := config.Config{DataRoot: t.TempDir()}
|
|
leftover := filepath.Join(cfg.XDGDataDir(), "reims-ctl", "vms", "macos-tahoe2")
|
|
if err := os.MkdirAll(leftover, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(leftover, "vm.toml"), []byte("name = \"macos-tahoe2\"\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
d := NewReimsMacOSDriver(func() config.Config { return cfg })
|
|
issues := d.ValidateCreate(context.Background(), driver.CreateRequest{
|
|
Name: "macos-tahoe2",
|
|
Options: map[string]any{
|
|
"cpus": 2,
|
|
"memory": "4G",
|
|
"disk_size": "64G",
|
|
},
|
|
})
|
|
found := false
|
|
for _, is := range issues {
|
|
if is.Field == "dir" {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatalf("expected dir validation issue for leftover VM folder, got %+v", issues)
|
|
}
|
|
}
|