mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
committed by
Bjørn Erik Pedersen
parent
983b8d537c
commit
6624979e1b
@@ -17,10 +17,9 @@ import (
|
||||
"html/template"
|
||||
"testing"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/gohugoio/hugo/config/testconfig"
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
@@ -808,3 +807,26 @@ func TestRepeat(t *testing.T) {
|
||||
c.Assert(result, qt.Equals, test.expect)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiff(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := qt.New(t)
|
||||
|
||||
for _, tt := range []struct {
|
||||
oldname string
|
||||
old any
|
||||
newname string
|
||||
new any
|
||||
expect string
|
||||
}{
|
||||
{"old", "foo\n", "new", "bar\n", "diff old new\n--- old\n+++ new\n@@ -1,1 +1,1 @@\n-foo\n+bar\n"},
|
||||
{"old", "foo\n", "new", "foo\n", ""},
|
||||
{"old", "foo\n", "new", "", "diff old new\n--- old\n+++ new\n@@ -1,1 +0,0 @@\n-foo\n"},
|
||||
{"old", "foo\n", "new", nil, "diff old new\n--- old\n+++ new\n@@ -1,1 +0,0 @@\n-foo\n"},
|
||||
{"old", "", "new", "", ""},
|
||||
} {
|
||||
|
||||
result := ns.Diff(tt.oldname, tt.old, tt.newname, tt.new)
|
||||
c.Assert(result, qt.Equals, tt.expect)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user