Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unused package import when response type and request type are in different packages #194

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tpl/hertz/server/standard/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ layouts:
}
{{end}}
{{if eq $MethodInfo.OutputDir "" -}}
resp,err := service.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req)
resp := &{{$MethodInfo.ReturnTypeName}}{}
resp,err = service.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req)
if err != nil {
utils.SendErrResponse(ctx, c, consts.StatusOK, err)
return
}
{{else}}
resp,err := {{$MethodInfo.OutputDir}}.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req)
resp := &{{$MethodInfo.ReturnTypeName}}{}
resp,err = {{$MethodInfo.OutputDir}}.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req)
if err != nil {
utils.SendErrResponse(ctx, c, consts.StatusOK, err)
return
Expand Down Expand Up @@ -133,7 +135,7 @@ layouts:
w := ut.PerformRequest(h.Engine, "{{.HTTPMethod}}", path, body,header)
resp := w.Result()
t.Log(string(resp.Body()))

// todo edit your unit test.
// assert.DeepEqual(t, 200, resp.StatusCode())
// assert.DeepEqual(t, "null", string(resp.Body()))
Expand All @@ -158,9 +160,9 @@ layouts:
w := ut.PerformRequest(h.Engine, "{{$MethodInfo.HTTPMethod}}", path, body,header)
resp := w.Result()
t.Log(string(resp.Body()))

// todo edit your unit test.
// assert.DeepEqual(t, 200, resp.StatusCode())
// assert.DeepEqual(t, "null", string(resp.Body()))
}
{{end}}
{{end}}
12 changes: 7 additions & 5 deletions tpl/hertz/server/standard_v2/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ layouts:
}
{{end}}
{{if eq $MethodInfo.OutputDir "" -}}
resp,err := service.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req)
resp := &{{$MethodInfo.ReturnTypeName}}{}
resp,err = service.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req)
if err != nil {
utils.SendErrResponse(ctx, c, consts.StatusInternalServerError, err)
return
}
{{else}}
resp,err := {{$MethodInfo.OutputDir}}.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req)
resp := &{{$MethodInfo.ReturnTypeName}}{}
resp,err = {{$MethodInfo.OutputDir}}.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req)
if err != nil {
utils.SendErrResponse(ctx, c, consts.StatusInternalServerError, err)
return
Expand Down Expand Up @@ -134,7 +136,7 @@ layouts:
w := ut.PerformRequest(h.Engine, "{{.HTTPMethod}}", path, body,header)
resp := w.Result()
t.Log(string(resp.Body()))

// todo edit your unit test.
// assert.DeepEqual(t, 200, resp.StatusCode())
// assert.DeepEqual(t, "null", string(resp.Body()))
Expand All @@ -159,9 +161,9 @@ layouts:
w := ut.PerformRequest(h.Engine, "{{$MethodInfo.HTTPMethod}}", path, body,header)
resp := w.Result()
t.Log(string(resp.Body()))

// todo edit your unit test.
// assert.DeepEqual(t, 200, resp.StatusCode())
// assert.DeepEqual(t, "null", string(resp.Body()))
}
{{end}}
{{end}}
Loading