MCPcopy Create free account
hub / github.com/antonmedv/gitmal / TestApplyTextFragment

Function TestApplyTextFragment

pkg/gitdiff/apply_test.go:12–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestApplyTextFragment(t *testing.T) {
13 tests := map[string]applyTest{
14 "createFile": {Files: getApplyFiles("text_fragment_new")},
15 "deleteFile": {Files: getApplyFiles("text_fragment_delete_all")},
16
17 "addStart": {Files: getApplyFiles("text_fragment_add_start")},
18 "addMiddle": {Files: getApplyFiles("text_fragment_add_middle")},
19 "addEnd": {Files: getApplyFiles("text_fragment_add_end")},
20 "addEndNoEOL": {Files: getApplyFiles("text_fragment_add_end_noeol")},
21
22 "changeStart": {Files: getApplyFiles("text_fragment_change_start")},
23 "changeMiddle": {Files: getApplyFiles("text_fragment_change_middle")},
24 "changeEnd": {Files: getApplyFiles("text_fragment_change_end")},
25 "changeEndEOL": {Files: getApplyFiles("text_fragment_change_end_eol")},
26 "changeExact": {Files: getApplyFiles("text_fragment_change_exact")},
27 "changeSingleNoEOL": {Files: getApplyFiles("text_fragment_change_single_noeol")},
28
29 "errorShortSrcBefore": {
30 Files: applyFiles{
31 Src: "text_fragment_error.src",
32 Patch: "text_fragment_error_short_src_before.patch",
33 },
34 Err: &Conflict{},
35 },
36 "errorShortSrc": {
37 Files: applyFiles{
38 Src: "text_fragment_error.src",
39 Patch: "text_fragment_error_short_src.patch",
40 },
41 Err: &Conflict{},
42 },
43 "errorContextConflict": {
44 Files: applyFiles{
45 Src: "text_fragment_error.src",
46 Patch: "text_fragment_error_context_conflict.patch",
47 },
48 Err: &Conflict{},
49 },
50 "errorDeleteConflict": {
51 Files: applyFiles{
52 Src: "text_fragment_error.src",
53 Patch: "text_fragment_error_delete_conflict.patch",
54 },
55 Err: &Conflict{},
56 },
57 "errorNewFile": {
58 Files: applyFiles{
59 Src: "text_fragment_error.src",
60 Patch: "text_fragment_error_new_file.patch",
61 },
62 Err: &Conflict{},
63 },
64 }
65
66 for name, test := range tests {
67 t.Run(name, func(t *testing.T) {
68 test.run(t, func(dst io.Writer, src io.ReaderAt, file *File) error {
69 if len(file.TextFragments) != 1 {

Callers

nothing calls this directly

Calls 4

ApplyFragmentMethod · 0.95
getApplyFilesFunction · 0.85
NewTextApplierFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected