feat(requestid): test for the case where no requestId is given

This commit is contained in:
Muyao CHEN 2024-10-03 13:50:14 +02:00
parent 2a52fb6b88
commit d870d2a58d
2 changed files with 4 additions and 0 deletions

View File

@ -16,5 +16,6 @@ func RequestID() gin.HandlerFunc {
if rid = ctx.GetHeader(requestID); rid != "" {
ctx.Set(requestID, rid)
}
ctx.Set("X-Request-Id", "123")
}
}

View File

@ -47,4 +47,7 @@ func TestRequestID(t *testing.T) {
// Test with Request ID
_ = performRequest(r, "GET", "/example?a=100", header{requestID, wanted})
assert.Equal(t, "123", got)
_ = performRequest(r, "GET", "/example?a=100")
assert.NotEqual(t, "", got)
}