"Fossies" - the Fresh Open Source Software Archive

Member "gin-1.7.7/context_1.17_test.go" (24 Nov 2021, 760 Bytes) of package /linux/www/gin-1.7.7.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2021 Gin Core Team.  All rights reserved.
    2 // Use of this source code is governed by a MIT style
    3 // license that can be found in the LICENSE file.
    4 
    5 //go:build go1.17
    6 // +build go1.17
    7 
    8 package gin
    9 
   10 import (
   11     "bytes"
   12     "mime/multipart"
   13     "net/http"
   14     "net/http/httptest"
   15     "testing"
   16 
   17     "github.com/stretchr/testify/assert"
   18 )
   19 
   20 func TestContextFormFileFailed17(t *testing.T) {
   21     buf := new(bytes.Buffer)
   22     mw := multipart.NewWriter(buf)
   23     mw.Close()
   24     c, _ := CreateTestContext(httptest.NewRecorder())
   25     c.Request, _ = http.NewRequest("POST", "/", nil)
   26     c.Request.Header.Set("Content-Type", mw.FormDataContentType())
   27     c.engine.MaxMultipartMemory = 8 << 20
   28     assert.Panics(t, func() {
   29         f, err := c.FormFile("file")
   30         assert.Error(t, err)
   31         assert.Nil(t, f)
   32     })
   33 }