| 1 | package thin |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "reflect" |
| 7 | "testing" |
| 8 | |
| 9 | "amadan.net/oficina/equipo/internal/runner/mac" |
| 10 | ) |
| 11 | |
| 12 | // Discovery on a Mac finds no claude: not EQUIPO_CLAUDE_PATH, not one on |
| 13 | // the usual paths. The only Claude Code a Mac worker knows is the pinned |
| 14 | // one under its install dir, which it verifies and never looks up. |
| 15 | func TestMacToolsNeverFindAClaude(t *testing.T) { |
| 16 | root := t.TempDir() |
| 17 | home, install := filepath.Join(root, "home"), filepath.Join(root, "home", ".local", "lib", "equipo-runner") |
| 18 | planted := []string{filepath.Join(root, "env", "claude"), filepath.Join(home, ".local", "bin", "claude")} |
| 19 | for _, p := range planted { |
| 20 | if err := os.MkdirAll(filepath.Dir(p), 0700); err != nil { |
| 21 | t.Fatal(err) |
| 22 | } |
| 23 | if err := os.WriteFile(p, []byte("#!/bin/sh\necho 2.1.312\n"), 0700); err != nil { |
| 24 | t.Fatal(err) |
| 25 | } |
| 26 | } |
| 27 | env := map[string]string{"EQUIPO_CLAUDE_PATH": planted[0]} |
| 28 | tools := macTools(install, home, func(k string) string { return env[k] }) |
| 29 | v := reflect.ValueOf(tools) |
| 30 | for i := range v.NumField() { |
| 31 | if f := v.Field(i); f.Kind() == reflect.String { |
| 32 | for _, p := range planted { |
| 33 | if f.String() == p { |
| 34 | t.Fatalf("Tools.%s is the unpinned %s", v.Type().Field(i).Name, p) |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | if tools.Claude != mac.NewClaudeCLI(home, install) || tools.Claude.Version() != "" { |
| 40 | t.Fatalf("Tools.Claude %+v", tools.Claude) |
| 41 | } |
| 42 | } |
| 43 | |