MCPcopy Create free account
hub / github.com/cwarden/git-add--interactive / TestSplitHunkNonSplittable

Function TestSplitHunkNonSplittable

internal/git/patch_test.go:466–554  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

464}
465
466func TestSplitHunkNonSplittable(t *testing.T) {
467 repo := &Repository{}
468
469 tests := []struct {
470 name string
471 hunk *Hunk
472 }{
473 {
474 name: "hunk without context between changes",
475 hunk: &Hunk{
476 Type: HunkTypeHunk,
477 OldLine: 1,
478 NewLine: 1,
479 Text: []string{
480 "@@ -1,4 +1,4 @@",
481 "-old line 1",
482 "+new line 1",
483 "-old line 2",
484 "+new line 2",
485 },
486 Display: []string{
487 "@@ -1,4 +1,4 @@",
488 "-old line 1",
489 "+new line 1",
490 "-old line 2",
491 "+new line 2",
492 },
493 },
494 },
495 {
496 name: "single change hunk",
497 hunk: &Hunk{
498 Type: HunkTypeHunk,
499 OldLine: 5,
500 NewLine: 5,
501 Text: []string{
502 "@@ -5,3 +5,3 @@",
503 " context before",
504 "-old line",
505 "+new line",
506 " context after",
507 },
508 Display: []string{
509 "@@ -5,3 +5,3 @@",
510 " context before",
511 "-old line",
512 "+new line",
513 " context after",
514 },
515 },
516 },
517 }
518
519 for _, tt := range tests {
520 t.Run(tt.name, func(t *testing.T) {
521 // Parse the hunk header first
522 err := repo.parseHunkHeader(tt.hunk)
523 if err != nil {

Callers

nothing calls this directly

Calls 3

parseHunkHeaderMethod · 0.95
HunkSplittableMethod · 0.95
SplitHunkMethod · 0.95

Tested by

no test coverage detected