template/parse_test.go: use diff for easier eye debug
This commit is contained in:
parent
b37dee1a67
commit
b6b3cc901c
|
@ -4,10 +4,11 @@ package template
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
func TestParse(t *testing.T) {
|
||||||
|
@ -321,7 +322,7 @@ func TestParse(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for i, tc := range cases {
|
||||||
path, _ := filepath.Abs(fixtureDir(tc.File))
|
path, _ := filepath.Abs(fixtureDir(tc.File))
|
||||||
tpl, err := ParseFile(fixtureDir(tc.File))
|
tpl, err := ParseFile(fixtureDir(tc.File))
|
||||||
if (err != nil) != tc.Err {
|
if (err != nil) != tc.Err {
|
||||||
|
@ -334,8 +335,8 @@ func TestParse(t *testing.T) {
|
||||||
if tpl != nil {
|
if tpl != nil {
|
||||||
tpl.RawContents = nil
|
tpl.RawContents = nil
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(tpl, tc.Result) {
|
if diff := cmp.Diff(tpl, tc.Result); diff != "" {
|
||||||
t.Fatalf("bad: %s\n\n%#v\n\n%#v", tc.File, tpl, tc.Result)
|
t.Fatalf("[%d]bad: %v", i, diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue