mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-22 09:34:33 +08:00
#fix:add testing to improve code coverage for func GetPostFormArrayMap
add testing to improve code coverage for func GetPostFormArrayMap
This commit is contained in:
parent
bf9422515e
commit
3a820eb012
@ -53,6 +53,12 @@ func createMultipartRequest() *http.Request {
|
||||
must(mw.WriteField("time_location", "31/12/2016 14:55"))
|
||||
must(mw.WriteField("names[a]", "thinkerou"))
|
||||
must(mw.WriteField("names[b]", "tianou"))
|
||||
|
||||
must(mw.WriteField("arraymap[0][process_md5]", "c78655bc80301d76ed4fef1c1ea40a7d"))
|
||||
must(mw.WriteField("arraymap[0][process_path]", "c:/windows/system32/svchost.exe"))
|
||||
must(mw.WriteField("arraymap[0][process_name]", "svchost.exe"))
|
||||
//must(mw.WriteField("arraymap[1][process_name]", "svchost1.exe"))
|
||||
|
||||
req, err := http.NewRequest("POST", "/", body)
|
||||
must(err)
|
||||
req.Header.Set("Content-Type", MIMEMultipartPOSTForm+"; boundary="+boundary)
|
||||
@ -578,6 +584,13 @@ func TestContextPostFormMultipart(t *testing.T) {
|
||||
|
||||
dicts = c.PostFormMap("nokey")
|
||||
assert.Equal(t, 0, len(dicts))
|
||||
|
||||
arrmap, ok := c.GetPostFormArrayMap("arraymap")
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "c:/windows/system32/svchost.exe", arrmap[0]["process_path"])
|
||||
assert.Equal(t, "c78655bc80301d76ed4fef1c1ea40a7d", arrmap[0]["process_md5"])
|
||||
assert.Equal(t, "svchost.exe", arrmap[0]["process_name"])
|
||||
|
||||
}
|
||||
|
||||
func TestContextSetCookie(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user