Skip to content

Commit 678e262

Browse files
committed
additional test code
1 parent 949cf3b commit 678e262

File tree

17 files changed

+620
-74
lines changed

17 files changed

+620
-74
lines changed

cmd/sponge/commands/generate/handler-pb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func runGenHandlerPbCommand(moduleName string, serverName string, codes map[stri
131131
"userExample.pb.go", "userExample.pb.validate.go", "userExample_grpc.pb.go", "userExample_router.pb.go", // api/serverNameExample
132132
"systemCode_http.go", "systemCode_rpc.go", "userExample_rpc.go", // internal/ecode
133133
"init.go", "init_test.go", // internal/model
134-
"handler/userExample.go", "handler/userExample_test.go", // internal/handler
134+
"handler/userExample.go", "handler/userExample_test.go", "handler/userExample_logic_test.go", // internal/handler
135135
"doc.go", "cacheNameExample.go", "cacheNameExample_test.go", // internal/cache
136136
}
137137

cmd/sponge/commands/generate/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func runGenHandlerCommand(moduleName string, codes map[string]string, outPath st
117117
"routers.go", "routers_test.go", "routers_pbExample.go", "routers_pbExample_test.go", "userExample_router.go", // internal/routers
118118
"swagger_types.go", // internal/types
119119
"doc.go", "cacheNameExample.go", "cacheNameExample_test.go", // internal/cache
120-
"handler/userExample_logic.go", // internal/handler
120+
"handler/userExample_logic.go", "handler/userExample_logic_test.go", // internal/handler
121121
}
122122

123123
r.SetSubDirsAndFiles(subDirs)

cmd/sponge/commands/generate/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func runGenHTTPCommand(moduleName string, serverName string, projectName string,
150150
"routers_pbExample.go", "routers_pbExample_test.go", "userExample_router.go", // internal/routers
151151
"grpc.go", "grpc_option.go", "grpc_test.go", // internal/server
152152
"doc.go", "cacheNameExample.go", "cacheNameExample_test.go", // internal/cache
153-
"handler/userExample_logic.go", // internal/handler
153+
"handler/userExample_logic.go", "handler/userExample_logic_test.go", // internal/handler
154154
}
155155

156156
r.SetSubDirsAndFiles(subDirs, subFiles...)

codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ coverage:
77
status:
88
project:
99
default:
10-
target: '80'
10+
target: '75'
1111
patch:
1212
default:
1313
target: '60'

internal/handler/userExample.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (h *userExampleHandler) Create(c *gin.Context) {
9696
func (h *userExampleHandler) DeleteByID(c *gin.Context) {
9797
_, id, isAbort := getUserExampleIDFromPath(c)
9898
if isAbort {
99+
response.Error(c, ecode.InvalidParams)
99100
return
100101
}
101102

@@ -152,6 +153,7 @@ func (h *userExampleHandler) DeleteByIDs(c *gin.Context) {
152153
func (h *userExampleHandler) UpdateByID(c *gin.Context) {
153154
_, id, isAbort := getUserExampleIDFromPath(c)
154155
if isAbort {
156+
response.Error(c, ecode.InvalidParams)
155157
return
156158
}
157159

@@ -194,6 +196,7 @@ func (h *userExampleHandler) UpdateByID(c *gin.Context) {
194196
func (h *userExampleHandler) GetByID(c *gin.Context) {
195197
idStr, id, isAbort := getUserExampleIDFromPath(c)
196198
if isAbort {
199+
response.Error(c, ecode.InvalidParams)
197200
return
198201
}
199202

@@ -358,7 +361,6 @@ func getUserExampleIDFromPath(c *gin.Context) (string, uint64, bool) {
358361
id, err := utils.StrToUint64E(idStr)
359362
if err != nil || id == 0 {
360363
logger.Warn("StrToUint64E error: ", logger.String("idStr", idStr), middleware.GCtxRequestIDField(c))
361-
response.Error(c, ecode.InvalidParams)
362364
return "", 0, true
363365
}
364366

0 commit comments

Comments
 (0)