diff --git a/assets/test/templates/common/fill.tmpl b/assets/test/templates/common/fill.tmpl index 25d82c4677..c66d3b56c7 100644 --- a/assets/test/templates/common/fill.tmpl +++ b/assets/test/templates/common/fill.tmpl @@ -1,28 +1,37 @@ {{define "fill" }} - {{- range . }} - {{ Param . }}: {{ $typ := .Type.String -}} - {{- if eq $typ "int8" -}} 0, - {{- else if eq $typ "uint8" -}} 0, - {{- else if eq $typ "uint16" -}} 0, - {{- else if eq $typ "uint32" -}} 0, - {{- else if eq $typ "uint64" -}} 0, - {{- else if eq $typ "uint" -}} 0, - {{- else if eq $typ "uintptr" -}} 0, - {{- else if eq $typ "int8" -}} 0, - {{- else if eq $typ "int16" -}} 0, - {{- else if eq $typ "int32" -}} 0, - {{- else if eq $typ "int64" -}} 0, - {{- else if eq $typ "int" -}} 0, - {{- else if eq $typ "float32" -}} 0, - {{- else if eq $typ "float64" -}} 0, - {{- else if eq $typ "complex64" -}} 0+0i, - {{- else if eq $typ "complex128" -}} 0+0i, - {{- else if eq $typ "byte" -}} 0, - {{- else if eq $typ "rune" -}} 0, - {{- else if eq $typ "string" -}} "", - {{- else if eq $typ "bool" -}} false, - {{- else if .IsStruct -}} {{.Type.Value}}{}, - {{- else -}} nil, + {{- range . }} {{ $typ := .Type.String -}} + {{- if and (ne $typ "sync.Map") + (ne $typ "sync.Mutex") + (ne $typ "sync.RWMutex") + (ne $typ "sync.Once") + (ne $typ "sync.Map") + (ne $typ "sync.WaitGroup") + (ne $typ "sync.Cond") + (ne $typ "sync.Pool") }} + {{ Param . }}: + {{- if eq $typ "int8" -}} 0, + {{- else if eq $typ "uint8" -}} 0, + {{- else if eq $typ "uint16" -}} 0, + {{- else if eq $typ "uint32" -}} 0, + {{- else if eq $typ "uint64" -}} 0, + {{- else if eq $typ "uint" -}} 0, + {{- else if eq $typ "uintptr" -}} 0, + {{- else if eq $typ "int8" -}} 0, + {{- else if eq $typ "int16" -}} 0, + {{- else if eq $typ "int32" -}} 0, + {{- else if eq $typ "int64" -}} 0, + {{- else if eq $typ "int" -}} 0, + {{- else if eq $typ "float32" -}} 0, + {{- else if eq $typ "float64" -}} 0, + {{- else if eq $typ "complex64" -}} 0+0i, + {{- else if eq $typ "complex128" -}} 0+0i, + {{- else if eq $typ "byte" -}} 0, + {{- else if eq $typ "rune" -}} 0, + {{- else if eq $typ "string" -}} "", + {{- else if eq $typ "bool" -}} false, + {{- else if .IsStruct -}} {{.Type.Value}}{}, + {{- else -}} nil, + {{- end -}} {{- end -}} {{ end -}} -{{ end }} +{{ end }} \ No newline at end of file diff --git a/assets/test/templates/common/function.tmpl b/assets/test/templates/common/function.tmpl index e8db37c6c5..3c137818cd 100644 --- a/assets/test/templates/common/function.tmpl +++ b/assets/test/templates/common/function.tmpl @@ -14,8 +14,17 @@ func {{ .TestName }}(t *testing.T) { {{- if .IsStruct }} {{- if .Fields}} type fields struct { {{ $hasFields = true }} - {{- range .Fields }} - {{ Field . }} {{ .Type }} + {{- range .Fields }} {{ $typ := .Type.String -}} + {{- if and (ne $typ "sync.Map") + (ne $typ "sync.Mutex") + (ne $typ "sync.RWMutex") + (ne $typ "sync.Once") + (ne $typ "sync.Map") + (ne $typ "sync.WaitGroup") + (ne $typ "sync.Cond") + (ne $typ "sync.Pool") }} + {{ Field . }} {{ .Type }} + {{- end -}} {{- end }} } {{- end }} @@ -138,8 +147,17 @@ func {{ .TestName }}(t *testing.T) { {{- with .Receiver }} {{- if .IsStruct }} {{ Receiver . }} := {{- if .Type.IsStar }}&{{- end }}{{ .Type.Value }} { - {{- range .Fields }} - {{ Field . }}: test.fields.{{ Field . }}, + {{- range .Fields }} {{ $typ := .Type.String -}} + {{- if and (ne $typ "sync.Map") + (ne $typ "sync.Mutex") + (ne $typ "sync.RWMutex") + (ne $typ "sync.Once") + (ne $typ "sync.Map") + (ne $typ "sync.WaitGroup") + (ne $typ "sync.Cond") + (ne $typ "sync.Pool") }} + {{ Field . }}: test.fields.{{ Field . }}, + {{- end }} {{- end }} } {{- end }}