| 1 | package mac |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/wire" |
| 8 | ) |
| 9 | |
| 10 | // codedProbes: every P probe's detail is codes with parameters, never |
| 11 | // words (whole-branch fix 1, #6). |
| 12 | func codedProbes(t *testing.T, ps ...wire.Probe) { |
| 13 | t.Helper() |
| 14 | for _, p := range ps { |
| 15 | if parts, ok := wire.ParseProbeDetail(p.Detail); !ok || len(parts) == 0 { |
| 16 | t.Errorf("%s: detail %q is not coded", p.ID, p.Detail) |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | func TestProbeDetailsCoded(t *testing.T) { |
| 22 | f := newProbeFixture(t, allLines("denied")) |
| 23 | codedProbes(t, RunProbes(context.Background(), f.h).Probes...) |
| 24 | // P2's srt failures are checked coded where they are made |
| 25 | // (TestP2SaysWhichStepFailed). |
| 26 | f = newProbeFixture(t, allLines("denied")) |
| 27 | caps := Capabilities(context.Background(), f.h.Exec, f.h.Tools) |
| 28 | caps.Simulators = nil |
| 29 | p, _, _ := probeP2(context.Background(), f.h, caps) |
| 30 | codedProbes(t, p) |
| 31 | f.h.Tools.SRT = "" |
| 32 | p, _, _ = probeP2(context.Background(), f.h, caps) |
| 33 | codedProbes(t, p) |
| 34 | f = newProbeFixture(t, nil) |
| 35 | f.h.Exposed = func(p string) bool { return p == "/Users/paul" } |
| 36 | codedProbes(t, probeP4(context.Background(), f.h)) |
| 37 | f.h.Paths.HomesUnknown = true |
| 38 | codedProbes(t, probeP4(context.Background(), f.h)) |
| 39 | } |
| 40 | |