Skip to content

Commit cb9d620

Browse files
Update middleware/requestid_test.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 387f056 commit cb9d620

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

middleware/requestid_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,23 @@ func TestSetRequestIdWitoutIncomingHeader(t *testing.T) {
4545
handlerToTest.ServeHTTP(httptest.NewRecorder(), req)
4646
}
4747

48+
import (
49+
"context"
50+
"net/http"
51+
"net/http/httptest"
52+
"testing"
53+
54+
"github.com/platform-mesh/golang-commons/context/keys"
55+
"github.com/platform-mesh/golang-commons/logger"
56+
"github.com/stretchr/testify/assert"
57+
)
58+
4859
func TestSetRequestIdInLogger(t *testing.T) {
4960
// This test verifies that SetRequestIdInLogger creates a request-aware logger
5061
nextHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
5162
// The logger in context should be updated with request information
63+
log := logger.LoadLoggerFromContext(r.Context())
64+
assert.NotNil(t, log)
5265
w.WriteHeader(http.StatusOK)
5366
})
5467

0 commit comments

Comments
 (0)