MCPcopy Create free account
hub / github.com/gogs/gogs / Test_diffsToHTML

Function Test_diffsToHTML

internal/gitutil/diff_test.go:13–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func Test_diffsToHTML(t *testing.T) {
14 tests := []struct {
15 diffs []dmp.Diff
16 lineType git.DiffLineType
17 expHTML template.HTML
18 }{
19 {
20 diffs: []dmp.Diff{
21 {Type: dmp.DiffEqual, Text: "foo "},
22 {Type: dmp.DiffInsert, Text: "bar"},
23 {Type: dmp.DiffDelete, Text: " baz"},
24 {Type: dmp.DiffEqual, Text: " biz"},
25 },
26 lineType: git.DiffLineAdd,
27 expHTML: template.HTML(`+foo <span class="added-code">bar</span> biz`),
28 },
29 {
30 diffs: []dmp.Diff{
31 {Type: dmp.DiffEqual, Text: "foo "},
32 {Type: dmp.DiffDelete, Text: "bar"},
33 {Type: dmp.DiffInsert, Text: " baz"},
34 {Type: dmp.DiffEqual, Text: " biz"},
35 },
36 lineType: git.DiffLineDelete,
37 expHTML: template.HTML(`-foo <span class="removed-code">bar</span> biz`),
38 },
39 }
40 for _, test := range tests {
41 t.Run("", func(t *testing.T) {
42 assert.Equal(t, test.expHTML, diffsToHTML(test.diffs, test.lineType))
43 })
44 }
45}

Callers

nothing calls this directly

Calls 2

diffsToHTMLFunction · 0.85
HTMLMethod · 0.80

Tested by

no test coverage detected