From 7ad9da1af08dfe6c874c0cd02edd21fd1bc360f4 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 9 Jun 2020 12:14:58 +0900 Subject: [PATCH 1/2] fix: template bug Signed-off-by: hlts2 --- assets/test/templates/common/function.tmpl | 2 +- assets/test/templates/option/function.tmpl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/test/templates/common/function.tmpl b/assets/test/templates/common/function.tmpl index 2bfe85d647..f852e71c05 100644 --- a/assets/test/templates/common/function.tmpl +++ b/assets/test/templates/common/function.tmpl @@ -109,7 +109,7 @@ func {{ .TestName }}(t *testing.T) { for {{- if (or .Subtests (not .IsNaked)) }} _, test := {{- end }} range tests { {{- if .Subtests }} t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc({{- if .TestParameters }} test.args {{- end }}) } diff --git a/assets/test/templates/option/function.tmpl b/assets/test/templates/option/function.tmpl index 116b5cb28d..78b8bb9e79 100644 --- a/assets/test/templates/option/function.tmpl +++ b/assets/test/templates/option/function.tmpl @@ -64,7 +64,7 @@ func {{ .TestName }}(t *testing.T) { /* defaultCheckFunc := func(w want, obj *T) error { if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got = %v, want %v", obj, w.c) + return errors.Errorf("got = %v, want %v", obj, w.obj) } return nil } @@ -117,7 +117,7 @@ func {{ .TestName }}(t *testing.T) { for {{- if (or .Subtests (not .IsNaked)) }} _, test := {{- end }} range tests { {{- if .Subtests }} t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc({{- if .TestParameters }} test.args {{- end }}) } @@ -138,7 +138,7 @@ func {{ .TestName }}(t *testing.T) { } */ - // Uncomment this block if the option returns an error, otherwise delete it + // Uncomment this block if the option do not return an error, otherwise delete it /* if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -146,7 +146,7 @@ func {{ .TestName }}(t *testing.T) { got := {{ template "call" $f }} obj := new(T) got(obj) - if err := test.checkFunc(tt.want, obj); err != nil { + if err := test.checkFunc(test.want, obj); err != nil { tt.Errorf("error = %v", err) } */ From 6d10e1aeb7111475e14139e10b0ed84644bb7627 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 9 Jun 2020 12:29:15 +0900 Subject: [PATCH 2/2] fix: comment Signed-off-by: hlts2 --- assets/test/templates/option/function.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/test/templates/option/function.tmpl b/assets/test/templates/option/function.tmpl index 78b8bb9e79..ff4876f934 100644 --- a/assets/test/templates/option/function.tmpl +++ b/assets/test/templates/option/function.tmpl @@ -2,6 +2,7 @@ {{- $f := . }} func {{ .TestName }}(t *testing.T) { + // Change interface type to the type of object you are testing type T = interface{} {{- if .TestParameters }} type args struct {