Fix TestSendParallel by using only a single DB connection
see https://github.com/mattn/go-sqlite3/issues/274 see https://github.com/mattn/go-sqlite3/issues/209 see https://stackoverflow.com/questions/32479071/sqlite3-error-database-is-locked-in-golang
This commit is contained in:
@@ -13,7 +13,9 @@ func NewEngine(cfg scn.Config) *gin.Engine {
|
||||
engine.RedirectFixedPath = false
|
||||
engine.RedirectTrailingSlash = false
|
||||
|
||||
engine.Use(CorsMiddleware())
|
||||
if cfg.Cors {
|
||||
engine.Use(CorsMiddleware())
|
||||
}
|
||||
|
||||
if cfg.GinDebug {
|
||||
ginlogger := gin.Logger()
|
||||
|
||||
@@ -51,6 +51,16 @@ func (j dataHTTPResponse) Write(g *gin.Context) {
|
||||
g.Data(j.statusCode, j.contentType, j.data)
|
||||
}
|
||||
|
||||
type errorHTTPResponse struct {
|
||||
statusCode int
|
||||
data any
|
||||
error error
|
||||
}
|
||||
|
||||
func (j errorHTTPResponse) Write(g *gin.Context) {
|
||||
g.JSON(j.statusCode, j.data)
|
||||
}
|
||||
|
||||
func Status(sc int) HTTPResponse {
|
||||
return &emptyHTTPResponse{statusCode: sc}
|
||||
}
|
||||
@@ -98,7 +108,7 @@ func createApiError(g *gin.Context, ident string, status int, errorid apierr.API
|
||||
Msg(fmt.Sprintf("[%s] %s", ident, msg))
|
||||
|
||||
if scn.Conf.ReturnRawErrors {
|
||||
return &jsonHTTPResponse{
|
||||
return &errorHTTPResponse{
|
||||
statusCode: status,
|
||||
data: apiError{
|
||||
Success: false,
|
||||
@@ -108,9 +118,10 @@ func createApiError(g *gin.Context, ident string, status int, errorid apierr.API
|
||||
RawError: langext.Ptr(langext.Conditional(e == nil, "", fmt.Sprintf("%+v", e))),
|
||||
Trace: string(debug.Stack()),
|
||||
},
|
||||
error: e,
|
||||
}
|
||||
} else {
|
||||
return &jsonHTTPResponse{
|
||||
return &errorHTTPResponse{
|
||||
statusCode: status,
|
||||
data: apiError{
|
||||
Success: false,
|
||||
@@ -118,6 +129,7 @@ func createApiError(g *gin.Context, ident string, status int, errorid apierr.API
|
||||
ErrorHighlight: int(highlight),
|
||||
Message: msg,
|
||||
},
|
||||
error: e,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user