(t *testing.T)
| 222 | } |
| 223 | |
| 224 | func TestParseHunks(t *testing.T) { |
| 225 | repo := &Repository{} |
| 226 | diffLines := []string{ |
| 227 | "diff --git a/test.txt b/test.txt", |
| 228 | "index 1234567..abcdefg 100644", |
| 229 | "--- a/test.txt", |
| 230 | "+++ b/test.txt", |
| 231 | "@@ -1,3 +1,4 @@", |
| 232 | " line 1", |
| 233 | "-line 2", |
| 234 | "+line 2 modified", |
| 235 | "+line 2.5", |
| 236 | " line 3", |
| 237 | "@@ -10,2 +11,3 @@", |
| 238 | " line 10", |
| 239 | "+new line", |
| 240 | " line 11", |
| 241 | } |
| 242 | |
| 243 | hunks, err := repo.parseHunks(diffLines, diffLines) |
| 244 | if err != nil { |
| 245 | t.Fatalf("Failed to parse hunks: %v", err) |
| 246 | } |
| 247 | |
| 248 | if len(hunks) != 3 { |
| 249 | t.Errorf("Expected 3 hunks (header + 2 actual hunks), got %d", len(hunks)) |
| 250 | } |
| 251 | |
| 252 | if hunks[0].Type != HunkTypeHeader { |
| 253 | t.Errorf("First hunk should be header, got %s", hunks[0].Type) |
| 254 | } |
| 255 | |
| 256 | if hunks[1].Type != HunkTypeHunk { |
| 257 | t.Errorf("Second hunk should be hunk, got %s", hunks[1].Type) |
| 258 | } |
| 259 | |
| 260 | if hunks[2].Type != HunkTypeHunk { |
| 261 | t.Errorf("Third hunk should be hunk, got %s", hunks[2].Type) |
| 262 | } |
| 263 | |
| 264 | if len(hunks[1].Text) != 6 { |
| 265 | t.Errorf("First actual hunk should have 6 lines, got %d", len(hunks[1].Text)) |
| 266 | } |
| 267 | |
| 268 | if !strings.HasPrefix(hunks[1].Text[0], "@@ -1,3 +1,4 @@") { |
| 269 | t.Errorf("First hunk should start with @@ header, got %s", hunks[1].Text[0]) |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | func TestHunkSplittingWithContext(t *testing.T) { |
| 274 | repo := &Repository{} |
nothing calls this directly
no test coverage detected