File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ type ErrTemplateNotFound struct {
88}
99
1010func (e ErrTemplateNotFound ) Error () string {
11- return fmt .Sprintf ("template %s not found" , e .Name )
11+ return fmt .Sprintf ("template '%s' not found" , e .Name )
1212}
1313
1414// ErrTemplateExecution is returned when a template fails to execute.
@@ -18,7 +18,7 @@ type ErrTemplateExecution struct {
1818}
1919
2020func (e ErrTemplateExecution ) Error () string {
21- return fmt .Sprintf ("failed to execute template %s: %v " , e .Name , e .Err )
21+ return fmt .Sprintf ("failed to execute template '%s': '%v' " , e .Name , e .Err )
2222}
2323
2424func (e ErrTemplateExecution ) Unwrap () error {
Original file line number Diff line number Diff line change 1+ package templator
2+
3+ import (
4+ "errors"
5+ "testing"
6+
7+ "github.com/stretchr/testify/assert"
8+ )
9+
10+ func TestErrTemplateNotFound_Error (t * testing.T ) {
11+ t .Parallel ()
12+
13+ e := ErrTemplateNotFound {Name : "foo" }
14+
15+ got := e .Error ()
16+ assert .Equal (t , "template 'foo' not found" , got )
17+ }
18+
19+ func TestErrTemplateExecution_Error (t * testing.T ) {
20+ t .Parallel ()
21+
22+ e := ErrTemplateExecution {
23+ Name : "foo" ,
24+ Err : errors .New ("bar" ),
25+ }
26+
27+ got := e .Error ()
28+ assert .Equal (t , "failed to execute template 'foo': 'bar'" , got )
29+ }
Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ func Test_validateField(t *testing.T) {
9292
9393 for _ , tc := range testCases {
9494 t .Run (tc .name , func (t * testing.T ) {
95+ t .Parallel ()
96+
9597 err := validateField (tc .typ , tc .fieldPath )
9698
9799 if tc .wantErr {
You can’t perform that action at this time.
0 commit comments