mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
fix #2158 and more
This commit is contained in:
@@ -11,14 +11,14 @@ func TestMVCOverlapping(t *testing.T) {
|
||||
|
||||
e := httptest.New(t, app, httptest.URL("http://example.com"))
|
||||
// unauthenticated.
|
||||
e.GET("/user").Expect().Status(httptest.StatusOK).Body().Equal("custom action to redirect on authentication page")
|
||||
e.GET("/user").Expect().Status(httptest.StatusOK).Body().IsEqual("custom action to redirect on authentication page")
|
||||
// login.
|
||||
e.POST("/user/login").Expect().Status(httptest.StatusOK)
|
||||
// authenticated.
|
||||
e.GET("/user").Expect().Status(httptest.StatusOK).Body().Equal(`UserController.Get: The Authenticated type
|
||||
e.GET("/user").Expect().Status(httptest.StatusOK).Body().IsEqual(`UserController.Get: The Authenticated type
|
||||
can be used to secure a controller's method too.`)
|
||||
// logout.
|
||||
e.POST("/user/logout").Expect().Status(httptest.StatusOK)
|
||||
// unauthenticated.
|
||||
e.GET("/user").Expect().Status(httptest.StatusOK).Body().Equal("custom action to redirect on authentication page")
|
||||
e.GET("/user").Expect().Status(httptest.StatusOK).Body().IsEqual("custom action to redirect on authentication page")
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ func TestControllerHandleHTTPError(t *testing.T) {
|
||||
app := newApp()
|
||||
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/").Expect().Status(httptest.StatusOK).Body().Equal(expectedIndex)
|
||||
e.GET("/a_notefound").Expect().Status(httptest.StatusNotFound).ContentType("text/html").Body().Equal(expectedNotFound)
|
||||
e.GET("/").Expect().Status(httptest.StatusOK).Body().IsEqual(expectedIndex)
|
||||
e.GET("/a_notefound").Expect().Status(httptest.StatusNotFound).ContentType("text/html").Body().IsEqual(expectedNotFound)
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ func TestGRPCCompatible(t *testing.T) {
|
||||
e := httptest.New(t, app)
|
||||
e.POST("/helloworld.Greeter/SayHello").WithJSON(map[string]string{"name": "makis"}).Expect().
|
||||
Status(httptest.StatusOK).
|
||||
JSON().Equal(map[string]string{"message": "Hello makis"})
|
||||
JSON().IsEqual(map[string]string{"message": "Hello makis"})
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ func TestMVCHelloWorld(t *testing.T) {
|
||||
e := httptest.New(t, newApp())
|
||||
|
||||
e.GET("/").Expect().Status(httptest.StatusOK).
|
||||
ContentType("text/html", "utf-8").Body().Equal("<h1>Welcome</h1>")
|
||||
ContentType("text/html", "utf-8").Body().IsEqual("<h1>Welcome</h1>")
|
||||
|
||||
e.GET("/ping").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("pong")
|
||||
Body().IsEqual("pong")
|
||||
|
||||
e.GET("/hello").Expect().Status(httptest.StatusOK).
|
||||
JSON().Object().Value("message").Equal("Hello Iris!")
|
||||
|
||||
e.GET("/custom_path").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("hello from the custom handler without following the naming guide")
|
||||
Body().IsEqual("hello from the custom handler without following the naming guide")
|
||||
}
|
||||
|
||||
@@ -13,21 +13,21 @@ func TestVersionedController(t *testing.T) {
|
||||
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "1.0.0").Expect().
|
||||
Status(iris.StatusOK).Body().Equal("data (v1.x)")
|
||||
Status(iris.StatusOK).Body().IsEqual("data (v1.x)")
|
||||
e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "2.3.0").Expect().
|
||||
Status(iris.StatusOK).Body().Equal("data (v2.x)")
|
||||
Status(iris.StatusOK).Body().IsEqual("data (v2.x)")
|
||||
e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "3.1.0").Expect().
|
||||
Status(iris.StatusOK).Body().Equal("data (v3.x)")
|
||||
Status(iris.StatusOK).Body().IsEqual("data (v3.x)")
|
||||
|
||||
// Test invalid version or no version at all.
|
||||
e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "4.0.0").Expect().
|
||||
Status(iris.StatusOK).Body().Equal("data")
|
||||
Status(iris.StatusOK).Body().IsEqual("data")
|
||||
e.GET("/data").Expect().
|
||||
Status(iris.StatusOK).Body().Equal("data")
|
||||
Status(iris.StatusOK).Body().IsEqual("data")
|
||||
|
||||
// Test Deprecated (v1)
|
||||
ex := e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "1.0.0").Expect()
|
||||
ex.Status(iris.StatusOK).Body().Equal("data (v1.x)")
|
||||
ex.Status(iris.StatusOK).Body().IsEqual("data (v1.x)")
|
||||
ex.Header("X-API-Warn").Equal(opts.WarnMessage)
|
||||
expectedDateStr := opts.DeprecationDate.Format(app.ConfigurationReadOnly().GetTimeFormat())
|
||||
ex.Header("X-API-Deprecation-Date").Equal(expectedDateStr)
|
||||
|
||||
Reference in New Issue
Block a user