mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-15 03:42:15 +01:00
refactoring tests util methods + adding context tests
This commit is contained in:
29
test/context.go
Normal file
29
test/context.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// DummyEchoContext creates a
|
||||
// echo.Context without anything.
|
||||
func DummyEchoContext() echo.Context {
|
||||
e := echo.New()
|
||||
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
return e.NewContext(req, rec)
|
||||
}
|
||||
|
||||
// EchoContextMultipart creates a
|
||||
// echo.Context with form files.
|
||||
func EchoContextMultipart(t *testing.T) echo.Context {
|
||||
e := echo.New()
|
||||
body, contentType := MergeMultipartForm(t, nil)
|
||||
req := httptest.NewRequest(http.MethodPost, "/", body)
|
||||
req.Header.Set(echo.HeaderContentType, contentType)
|
||||
rec := httptest.NewRecorder()
|
||||
return e.NewContext(req, rec)
|
||||
}
|
||||
Reference in New Issue
Block a user