--- extractRelevantCode ---
(t *testing.T)
| 230 | // --- extractRelevantCode --- |
| 231 | |
| 232 | func TestExtractRelevantCode(t *testing.T) { |
| 233 | root := t.TempDir() |
| 234 | var sb strings.Builder |
| 235 | for i := 0; i < 10; i++ { |
| 236 | sb.WriteString("package main // filler\n") |
| 237 | } |
| 238 | writeTestFile(t, filepath.Join(root, "main.go"), sb.String()) |
| 239 | |
| 240 | traces := []StackTrace{ |
| 241 | { |
| 242 | Language: "go", |
| 243 | ExceptionType: "panic", |
| 244 | Frames: []string{"main.go:5", "not-a-frame"}, |
| 245 | }, |
| 246 | } |
| 247 | |
| 248 | snippets := extractRelevantCode(root, nil, traces) |
| 249 | if len(snippets) != 1 { |
| 250 | t.Fatalf("expected 1 snippet, got %d", len(snippets)) |
| 251 | } |
| 252 | if snippets[0].FilePath != "main.go" { |
| 253 | t.Errorf("FilePath = %q, want main.go", snippets[0].FilePath) |
| 254 | } |
| 255 | if !strings.Contains(snippets[0].Content, ">>") { |
| 256 | t.Errorf("snippet content missing target-line marker:\n%s", snippets[0].Content) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | // --- git-backed helpers --- |
| 261 |
nothing calls this directly
no test coverage detected