From 53670929c2e3ed4c4111ea9672695bad5f6f1b18 Mon Sep 17 00:00:00 2001 From: DevinZeng Date: Fri, 1 Nov 2024 15:46:08 +0800 Subject: [PATCH] fix: Handler_test.Tpl content error --bug=1 --- tools/goctl/api/gogen/handler_test.tpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/goctl/api/gogen/handler_test.tpl b/tools/goctl/api/gogen/handler_test.tpl index e99277324ed7..f461f4ddda65 100644 --- a/tools/goctl/api/gogen/handler_test.tpl +++ b/tools/goctl/api/gogen/handler_test.tpl @@ -62,8 +62,9 @@ func Test{{.HandlerName}}(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { tt.setupMocks() - reqBody := []byte{} - {{if .HasRequest}}reqBody, err := json.Marshal(tt.reqBody) + var reqBody []byte + {{if .HasRequest}}var err error + reqBody, err = json.Marshal(tt.reqBody) require.NoError(t, err){{end}} req, err := http.NewRequest("POST", "/ut", bytes.NewBuffer(reqBody)) require.NoError(t, err)