1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 20:07:04 +00:00

fix #2158 and more

This commit is contained in:
Gerasimos (Makis) Maropoulos
2023-07-08 02:08:18 +03:00
parent 757e7fe61b
commit 6add1ba49b
79 changed files with 551 additions and 467 deletions

View File

@@ -20,31 +20,31 @@ func TestReadBodyAndNegotiate(t *testing.T) {
// Test send JSON and receive JSON.
e.POST("/").WithJSON(expectedPayload).Expect().Status(httptest.StatusOK).
JSON().Equal(expectedPayload)
JSON().IsEqual(expectedPayload)
// Test send Form and receive XML.
e.POST("/").WithForm(expectedPayload).
WithHeader("Accept", "application/xml").
Expect().Status(httptest.StatusOK).
Body().Equal(expectedXMLPayload)
Body().IsEqual(expectedXMLPayload)
// Test send URL Query and receive MessagePack.
e.POST("/").WithQuery("message", expectedPayload.Message).
WithHeader("Accept", "application/msgpack").
Expect().Status(httptest.StatusOK).ContentType("application/msgpack").
Body().Equal(expectedMsgPackPayload)
Body().IsEqual(expectedMsgPackPayload)
// Test send MessagePack and receive MessagePack.
e.POST("/").WithBytes([]byte(expectedMsgPackPayload)).
WithHeader("Content-Type", "application/msgpack").
WithHeader("Accept", "application/msgpack").
Expect().Status(httptest.StatusOK).
ContentType("application/msgpack").Body().Equal(expectedMsgPackPayload)
ContentType("application/msgpack").Body().IsEqual(expectedMsgPackPayload)
// Test send YAML and receive YAML.
e.POST("/").WithBytes([]byte(expectedYAMLPayload)).
WithHeader("Content-Type", "application/x-yaml").
WithHeader("Accept", "application/x-yaml").
Expect().Status(httptest.StatusOK).
ContentType("application/x-yaml").Body().Equal(expectedYAMLPayload)
ContentType("application/x-yaml").Body().IsEqual(expectedYAMLPayload)
}

View File

@@ -13,5 +13,5 @@ func TestReadCustomPerType(t *testing.T) {
expectedResponse := `Received: main.config{Addr:"localhost:8080", ServerName:"Iris"}`
e.POST("/").WithText("addr: localhost:8080\nserverName: Iris").Expect().
Status(httptest.StatusOK).Body().Equal(expectedResponse)
Status(httptest.StatusOK).Body().IsEqual(expectedResponse)
}

View File

@@ -13,5 +13,5 @@ func TestReadCustomViaUnmarshaler(t *testing.T) {
expectedResponse := `Received: main.config{Addr:"localhost:8080", ServerName:"Iris"}`
e.POST("/").WithText("addr: localhost:8080\nserverName: Iris").Expect().
Status(httptest.StatusOK).Body().Equal(expectedResponse)
Status(httptest.StatusOK).Body().IsEqual(expectedResponse)
}

View File

@@ -12,5 +12,5 @@ func TestReadParams(t *testing.T) {
e := httptest.New(t, app)
expectedBody := `myParams: main.myParams{Name:"kataras", Age:27, Tail:[]string{"iris", "web", "framework"}}`
e.GET("/kataras/27/iris/web/framework").Expect().Status(httptest.StatusOK).Body().Equal(expectedBody)
e.GET("/kataras/27/iris/web/framework").Expect().Status(httptest.StatusOK).Body().IsEqual(expectedBody)
}

View File

@@ -12,5 +12,5 @@ func TestReadURL(t *testing.T) {
e := httptest.New(t, app)
expectedBody := `myURL: main.myURL{Name:"kataras", Age:27, Tail:[]string{"iris", "web", "framework"}}`
e.GET("/iris/web/framework").WithQuery("name", "kataras").WithQuery("age", 27).Expect().Status(httptest.StatusOK).Body().Equal(expectedBody)
e.GET("/iris/web/framework").WithQuery("name", "kataras").WithQuery("age", 27).Expect().Status(httptest.StatusOK).Body().IsEqual(expectedBody)
}

View File

@@ -14,5 +14,5 @@ func TestReadXML(t *testing.T) {
send := `<person name="Winston Churchill" age="90"><description>Description of this person, the body of this inner element.</description></person>`
e.POST("/").WithText(send).Expect().
Status(httptest.StatusOK).Body().Equal(expectedResponse)
Status(httptest.StatusOK).Body().IsEqual(expectedResponse)
}

View File

@@ -20,5 +20,5 @@ comments: >
Billsmer @ 338-4338.`
e.POST("/").WithHeader("Content-Type", "application/x-yaml").WithBytes([]byte(send)).Expect().
Status(httptest.StatusOK).Body().Equal(expectedResponse)
Status(httptest.StatusOK).Body().IsEqual(expectedResponse)
}