|
| 1 | +package skilldoc |
| 2 | + |
| 3 | +import ( |
| 4 | + "os" |
| 5 | + "path/filepath" |
| 6 | + "strings" |
| 7 | + "testing" |
| 8 | +) |
| 9 | + |
| 10 | +func TestFlashdutySkillGuidesLargeListScans(t *testing.T) { |
| 11 | + body := readSkillFile(t, "SKILL.md") |
| 12 | + incident := readSkillFile(t, "reference", "incident.md") |
| 13 | + insight := readSkillFile(t, "reference", "insight.md") |
| 14 | + |
| 15 | + for _, want := range []string{ |
| 16 | + "Large list scans", |
| 17 | + "redirect JSON to a temp file", |
| 18 | + "Do not dump page-sized JSON", |
| 19 | + } { |
| 20 | + if !strings.Contains(body, want) { |
| 21 | + t.Errorf("SKILL.md missing large-list guidance %q", want) |
| 22 | + } |
| 23 | + } |
| 24 | + for _, want := range []string{ |
| 25 | + "Do not re-run `incident alerts`, `incident similar`, `incident timeline`, or `change list`", |
| 26 | + "Page-sized scans go to files", |
| 27 | + } { |
| 28 | + if !strings.Contains(incident, want) { |
| 29 | + t.Errorf("incident card missing large-list/summary guidance %q", want) |
| 30 | + } |
| 31 | + } |
| 32 | + for _, want := range []string{ |
| 33 | + "For multi-dimensional reports, fetch once to a temp file", |
| 34 | + "Do not run the same account-wide list again for each `jq` bucket", |
| 35 | + } { |
| 36 | + if !strings.Contains(insight, want) { |
| 37 | + t.Errorf("insight card missing reusable JSON guidance %q", want) |
| 38 | + } |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +func readSkillFile(t *testing.T, parts ...string) string { |
| 43 | + t.Helper() |
| 44 | + p := filepath.Join(append([]string{"..", "..", "skills", "flashduty"}, parts...)...) |
| 45 | + b, err := os.ReadFile(p) |
| 46 | + if err != nil { |
| 47 | + t.Fatalf("read %s: %v", p, err) |
| 48 | + } |
| 49 | + return string(b) |
| 50 | +} |
0 commit comments