fix: remove t.Parallel() from metrics tests to fix race conditions
The Gin framework uses a global mode setting (gin.SetMode()) which is not thread-safe when tests run in parallel. Removing t.Parallel() from metrics tests that use gin.SetMode() prevents data races when running tests with the race detector enabled. All tests now pass with 'make test' which includes -race flag.
This commit is contained in:
@@ -34,13 +34,10 @@ func TestNewMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMetrics_HTTPMiddleware(t *testing.T) {
|
||||
t.Parallel()
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
metrics := NewMetrics()
|
||||
|
||||
// Set Gin to test mode
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
router := gin.New()
|
||||
router.Use(metrics.HTTPMiddleware())
|
||||
|
||||
@@ -63,12 +60,10 @@ func TestMetrics_HTTPMiddleware(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMetrics_HTTPMiddleware_Error(t *testing.T) {
|
||||
t.Parallel()
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
metrics := NewMetrics()
|
||||
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
router := gin.New()
|
||||
router.Use(metrics.HTTPMiddleware())
|
||||
|
||||
@@ -87,8 +82,6 @@ func TestMetrics_HTTPMiddleware_Error(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMetrics_Handler(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
metrics := NewMetrics()
|
||||
|
||||
handler := metrics.Handler()
|
||||
|
||||
Reference in New Issue
Block a user