Skip to content

Commit

Permalink
Useless package names when response type and request type are in diff…
Browse files Browse the repository at this point in the history
…erent packages (cloudwego#194)

Signed-off-by: rogerogers <[email protected]>
  • Loading branch information
rogerogers authored Jun 14, 2024
1 parent 14939c0 commit 2b831c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
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}}

0 comments on commit 2b831c5

Please sign in to comment.