MCPcopy Index your code
hub / github.com/labstack/echo / TestContextFormFile

Function TestContextFormFile

context_test.go:944–961  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

942}
943
944func TestContextFormFile(t *testing.T) {
945 e := New()
946 buf := new(bytes.Buffer)
947 mr := multipart.NewWriter(buf)
948 w, err := mr.CreateFormFile("file", "test")
949 if assert.NoError(t, err) {
950 w.Write([]byte("test"))
951 }
952 mr.Close()
953 req := httptest.NewRequest(http.MethodPost, "/", buf)
954 req.Header.Set(HeaderContentType, mr.FormDataContentType())
955 rec := httptest.NewRecorder()
956 c := e.NewContext(req, rec)
957 f, err := c.FormFile("file")
958 if assert.NoError(t, err) {
959 assert.Equal(t, "test", f.Filename)
960 }
961}
962
963func TestContextMultipartForm(t *testing.T) {
964 e := New()

Callers

nothing calls this directly

Calls 6

FormFileMethod · 0.95
NewFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80
WriteMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…