MCPcopy
hub / github.com/jesseduffield/lazygit / TestIsSingleHunkForWholeFile

Function TestIsSingleHunkForWholeFile

pkg/commands/patch/patch_test.go:714–773  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

712}
713
714func TestIsSingleHunkForWholeFile(t *testing.T) {
715 scenarios := []struct {
716 testName string
717 patchStr string
718 expectedResult bool
719 }{
720 {
721 testName: "simpleDiff",
722 patchStr: simpleDiff,
723 expectedResult: false,
724 },
725 {
726 testName: "addNewlineToEndOfFile",
727 patchStr: addNewlineToEndOfFile,
728 expectedResult: false,
729 },
730 {
731 testName: "removeNewlinefromEndOfFile",
732 patchStr: removeNewlinefromEndOfFile,
733 expectedResult: false,
734 },
735 {
736 testName: "twoHunks",
737 patchStr: twoHunks,
738 expectedResult: false,
739 },
740 {
741 testName: "twoChangesInOneHunk",
742 patchStr: twoChangesInOneHunk,
743 expectedResult: false,
744 },
745 {
746 testName: "newFile",
747 patchStr: newFile,
748 expectedResult: true,
749 },
750 {
751 testName: "deletedFile",
752 patchStr: deletedFile,
753 expectedResult: true,
754 },
755 {
756 testName: "addNewlineToPreviouslyEmptyFile",
757 patchStr: addNewlineToPreviouslyEmptyFile,
758 expectedResult: true,
759 },
760 {
761 testName: "exampleHunk",
762 patchStr: exampleHunk,
763 expectedResult: false,
764 },
765 }
766
767 for _, s := range scenarios {
768 t.Run(s.testName, func(t *testing.T) {
769 patch := Parse(s.patchStr)
770 assert.Equal(t, s.expectedResult, patch.IsSingleHunkForWholeFile())
771 })

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected