Unit tests TODO func (c *Context) File(filepath string) { func (c *Context) Negotiate(code int, config Negotiate) { BAD case: func (c *Context) Render(code int, render render.Render, obj ...any) { test that information is not leaked when reusing Contexts (using the Pool)
()
| 47 | // test that information is not leaked when reusing Contexts (using the Pool) |
| 48 | |
| 49 | func createMultipartRequest() *http.Request { |
| 50 | boundary := "--testboundary" |
| 51 | body := new(bytes.Buffer) |
| 52 | mw := multipart.NewWriter(body) |
| 53 | defer mw.Close() |
| 54 | |
| 55 | must(mw.SetBoundary(boundary)) |
| 56 | must(mw.WriteField("foo", "bar")) |
| 57 | must(mw.WriteField("bar", "10")) |
| 58 | must(mw.WriteField("bar", "foo2")) |
| 59 | must(mw.WriteField("array", "first")) |
| 60 | must(mw.WriteField("array", "second")) |
| 61 | must(mw.WriteField("id", "")) |
| 62 | must(mw.WriteField("time_local", "31/12/2016 14:55")) |
| 63 | must(mw.WriteField("time_utc", "31/12/2016 14:55")) |
| 64 | must(mw.WriteField("time_location", "31/12/2016 14:55")) |
| 65 | must(mw.WriteField("names[a]", "thinkerou")) |
| 66 | must(mw.WriteField("names[b]", "tianou")) |
| 67 | req, err := http.NewRequest(http.MethodPost, "/", body) |
| 68 | must(err) |
| 69 | req.Header.Set("Content-Type", MIMEMultipartPOSTForm+"; boundary="+boundary) |
| 70 | return req |
| 71 | } |
| 72 | |
| 73 | func must(err error) { |
| 74 | if err != nil { |
no test coverage detected