Documentation
¶
Index ¶
- func AssertFileContent(t TestingT, storage *storageTesting.FakeStorage, path string, ...)
- func AssertFileUploaded(t TestingT, storage *storageTesting.FakeStorage, expectedPath string)
- func GetUploadedFile(r *http.Request, fieldName string) (multipart.File, *multipart.FileHeader, error)
- func GetUploadedFiles(r *http.Request, fieldName string) ([]*multipart.FileHeader, error)
- func ParseMultipartForm(r *http.Request, maxMemory int64) error
- func SaveUploadedFile(file multipart.File, header *multipart.FileHeader, basePath string) (string, error)
- func TestMultipleUploads(files map[string]*storageTesting.FakeFile) *http.Request
- func TestUpload(fieldName string, file *storageTesting.FakeFile) *http.Request
- func TestUploadHandler(storage storageTesting.FakeStorage) http.HandlerFunc
- type TestUploadBuilder
- func (b *TestUploadBuilder) AddField(name, value string) *TestUploadBuilder
- func (b *TestUploadBuilder) AddFile(fieldName string, file *storageTesting.FakeFile) *TestUploadBuilder
- func (b *TestUploadBuilder) AddHeader(name, value string) *TestUploadBuilder
- func (b *TestUploadBuilder) AddRawFile(fieldName, fileName string, content []byte, mimeType string) *TestUploadBuilder
- func (b *TestUploadBuilder) Build(method, url string) (*http.Request, error)
- func (b *TestUploadBuilder) BuildTest(method, url string) *http.Request
- type TestingT
- type UploadResponse
- type UploadedFile
- type UploadedFileResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFileContent ¶
func AssertFileContent(t TestingT, storage *storageTesting.FakeStorage, path string, expectedContent []byte)
AssertFileContent checks if uploaded file has expected content
func AssertFileUploaded ¶
func AssertFileUploaded(t TestingT, storage *storageTesting.FakeStorage, expectedPath string)
AssertFileUploaded checks if a file was successfully uploaded
func GetUploadedFile ¶
func GetUploadedFile(r *http.Request, fieldName string) (multipart.File, *multipart.FileHeader, error)
GetUploadedFile retrieves an uploaded file from the request
func GetUploadedFiles ¶
GetUploadedFiles retrieves multiple uploaded files from the request
func ParseMultipartForm ¶
ParseMultipartForm is a helper to parse multipart form in tests
func SaveUploadedFile ¶
func SaveUploadedFile(file multipart.File, header *multipart.FileHeader, basePath string) (string, error)
SaveUploadedFile saves an uploaded file to storage (helper for handlers)
func TestMultipleUploads ¶
func TestMultipleUploads(files map[string]*storageTesting.FakeFile) *http.Request
TestMultipleUploads creates a request with multiple file uploads
func TestUpload ¶
func TestUpload(fieldName string, file *storageTesting.FakeFile) *http.Request
TestUpload creates a simple file upload request for testing
func TestUploadHandler ¶
func TestUploadHandler(storage storageTesting.FakeStorage) http.HandlerFunc
TestUploadHandler creates a test handler that processes file uploads
Types ¶
type TestUploadBuilder ¶
type TestUploadBuilder struct {
// contains filtered or unexported fields
}
TestUploadBuilder helps build test upload requests
func NewUploadBuilder ¶
func NewUploadBuilder() *TestUploadBuilder
NewUploadBuilder creates a new upload builder
func (*TestUploadBuilder) AddField ¶
func (b *TestUploadBuilder) AddField(name, value string) *TestUploadBuilder
AddField adds a form field to the upload
func (*TestUploadBuilder) AddFile ¶
func (b *TestUploadBuilder) AddFile(fieldName string, file *storageTesting.FakeFile) *TestUploadBuilder
AddFile adds a file to the upload
func (*TestUploadBuilder) AddHeader ¶
func (b *TestUploadBuilder) AddHeader(name, value string) *TestUploadBuilder
AddHeader adds a header to the request
func (*TestUploadBuilder) AddRawFile ¶
func (b *TestUploadBuilder) AddRawFile(fieldName, fileName string, content []byte, mimeType string) *TestUploadBuilder
AddRawFile adds a raw file to the upload
type TestingT ¶
type TestingT interface {
Helper()
Errorf(format string, args ...interface{})
}
TestingT is a subset of testing.T for helper functions
type UploadResponse ¶
type UploadResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Files []UploadedFileResponse `json:"files,omitempty"`
Errors map[string]string `json:"errors,omitempty"`
}
UploadResponse represents a typical upload response
type UploadedFile ¶
UploadedFile represents a file to be uploaded in tests
type UploadedFileResponse ¶
type UploadedFileResponse struct {
Name string `json:"name"`
Path string `json:"path"`
URL string `json:"url"`
Size int64 `json:"size"`
MimeType string `json:"mime_type"`
TemporaryURL string `json:"temporary_url,omitempty"`
}
UploadedFileResponse represents a single uploaded file in the response