mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
Improve middleware/requestid test suite (#2191)
Add a test scenario for client sent request id header.
This commit is contained in:
parent
6a449876e9
commit
6da1fe9cbc
|
@ -55,9 +55,17 @@ func TestRequestID(t *testing.T) {
|
|||
changeID.Get("/", h)
|
||||
}
|
||||
|
||||
const expectedClientSentID = "client sent id"
|
||||
clientSentID := app.Party("/client_id")
|
||||
{
|
||||
clientSentID.Use(requestid.New())
|
||||
clientSentID.Get("/", h)
|
||||
}
|
||||
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/default").Expect().Status(httptest.StatusOK).Body().NotEmpty()
|
||||
e.GET("/custom").Expect().Status(httptest.StatusOK).Body().IsEqual(expectedCustomID)
|
||||
e.GET("/custom_err").Expect().Status(httptest.StatusUnauthorized).Body().IsEqual(expectedErrMsg)
|
||||
e.GET("/custom_change_id").Expect().Status(httptest.StatusOK).Body().IsEqual(expectedCustomIDFromOtherMiddleware)
|
||||
e.GET("/client_id").WithHeader("X-Request-Id", expectedClientSentID).Expect().Header("X-Request-Id").IsEqual(expectedClientSentID)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user