Skip to content

Commit

Permalink
additional test code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufuyi committed Oct 15, 2023
1 parent 949cf3b commit 678e262
Show file tree
Hide file tree
Showing 17 changed files with 620 additions and 74 deletions.
2 changes: 1 addition & 1 deletion cmd/sponge/commands/generate/handler-pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func runGenHandlerPbCommand(moduleName string, serverName string, codes map[stri
"userExample.pb.go", "userExample.pb.validate.go", "userExample_grpc.pb.go", "userExample_router.pb.go", // api/serverNameExample
"systemCode_http.go", "systemCode_rpc.go", "userExample_rpc.go", // internal/ecode
"init.go", "init_test.go", // internal/model
"handler/userExample.go", "handler/userExample_test.go", // internal/handler
"handler/userExample.go", "handler/userExample_test.go", "handler/userExample_logic_test.go", // internal/handler
"doc.go", "cacheNameExample.go", "cacheNameExample_test.go", // internal/cache
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/sponge/commands/generate/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func runGenHandlerCommand(moduleName string, codes map[string]string, outPath st
"routers.go", "routers_test.go", "routers_pbExample.go", "routers_pbExample_test.go", "userExample_router.go", // internal/routers
"swagger_types.go", // internal/types
"doc.go", "cacheNameExample.go", "cacheNameExample_test.go", // internal/cache
"handler/userExample_logic.go", // internal/handler
"handler/userExample_logic.go", "handler/userExample_logic_test.go", // internal/handler
}

r.SetSubDirsAndFiles(subDirs)
Expand Down
2 changes: 1 addition & 1 deletion cmd/sponge/commands/generate/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func runGenHTTPCommand(moduleName string, serverName string, projectName string,
"routers_pbExample.go", "routers_pbExample_test.go", "userExample_router.go", // internal/routers
"grpc.go", "grpc_option.go", "grpc_test.go", // internal/server
"doc.go", "cacheNameExample.go", "cacheNameExample_test.go", // internal/cache
"handler/userExample_logic.go", // internal/handler
"handler/userExample_logic.go", "handler/userExample_logic_test.go", // internal/handler
}

r.SetSubDirsAndFiles(subDirs, subFiles...)
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ coverage:
status:
project:
default:
target: '80'
target: '75'
patch:
default:
target: '60'
Expand Down
4 changes: 3 additions & 1 deletion internal/handler/userExample.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (h *userExampleHandler) Create(c *gin.Context) {
func (h *userExampleHandler) DeleteByID(c *gin.Context) {
_, id, isAbort := getUserExampleIDFromPath(c)
if isAbort {
response.Error(c, ecode.InvalidParams)
return
}

Expand Down Expand Up @@ -152,6 +153,7 @@ func (h *userExampleHandler) DeleteByIDs(c *gin.Context) {
func (h *userExampleHandler) UpdateByID(c *gin.Context) {
_, id, isAbort := getUserExampleIDFromPath(c)
if isAbort {
response.Error(c, ecode.InvalidParams)
return
}

Expand Down Expand Up @@ -194,6 +196,7 @@ func (h *userExampleHandler) UpdateByID(c *gin.Context) {
func (h *userExampleHandler) GetByID(c *gin.Context) {
idStr, id, isAbort := getUserExampleIDFromPath(c)
if isAbort {
response.Error(c, ecode.InvalidParams)
return
}

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

Expand Down
Loading

0 comments on commit 678e262

Please sign in to comment.