package fprobe import ( "testing" "time" "amadan.net/oficina/equipo/internal/wire" ) // Whole-branch fix 1, #6: what the store says of a probe that has no // current result is a code, each reason its own. func TestStoreDetailsAreCoded(t *testing.T) { now := time.Date(2026, 11, 29, 12, 0, 0, 0, time.UTC) in := NewInputs("v1.0.0", true, wire.Xcode{Version: "27.2", Build: "27B52"}, []wire.Simulator{{Runtime: "iOS 27.2"}}) var s Store seen := map[string]bool{} note := func(ps []wire.Probe, id, code string) { t.Helper() coded(t, ps) p := byID(ps, id) if parts, _ := wire.ParseProbeDetail(p.Detail); len(parts) != 1 || parts[0].Code != code { t.Fatalf("%s: %q, want %s", id, p.Detail, code) } seen[code] = true } note(s.Probes(in, now, true), "F1", "not_run") note(s.Probes(in, now, false), "F5", "f5_skipped") s.Put(allPassed(in, now.Add(-25*time.Hour))[0]) note(s.Probes(in, now, true), "F1", "expired") s.Put(allPassed(in, now.Add(time.Hour))[0]) note(s.Probes(in, now, true), "F1", "future") for code, other := range map[string]Inputs{ "stale_runner": NewInputs("v1.0.1", true, wire.Xcode{Version: "27.2", Build: "27B52"}, []wire.Simulator{{Runtime: "iOS 27.2"}}), "stale_xcode": NewInputs("v1.0.0", true, wire.Xcode{Version: "27.3", Build: "27C1"}, []wire.Simulator{{Runtime: "iOS 27.2"}}), "stale_runtimes": NewInputs("v1.0.0", true, wire.Xcode{Version: "27.2", Build: "27B52"}, []wire.Simulator{{Runtime: "iOS 27.3"}}), } { var u Store u.Put(allPassed(in, now)[0]) note(u.Probes(other, now, true), "F1", code) } for _, ps := range [][]wire.Probe{ launched(LaunchA, Outcome{Reason: "account_unavailable"}), launched(LaunchA, Outcome{Reason: "a sentence, with words"}), launched(LaunchC, Outcome{Started: true}), undecided(LaunchA, Host{}, "inputs_changed").Probes, notRun(all(LaunchA, wire.ProbeDenied, wire.ProbeDetail("f1_denied")), "script_not_run"), notRun(all(LaunchA, wire.ProbeFailed, wire.ProbeDetail("allowed", "tcp")), "other_command"), } { coded(t, ps) } }