Documentation
¶
Index ¶
- type FakeFile
- type FakeFileBuilder
- func (b *FakeFileBuilder) Archive(name string, sizeInKB int) *FakeFile
- func (b *FakeFileBuilder) CSV(name string, rows int) *FakeFile
- func (b *FakeFileBuilder) Create(name string, sizeInKB int) *FakeFile
- func (b *FakeFileBuilder) CreateWithMimeType(name string, sizeInKB int, mimeType string) *FakeFile
- func (b *FakeFileBuilder) Image(name string, width, height int) *FakeFile
- func (b *FakeFileBuilder) JSON(name string, data interface{}) *FakeFile
- func (b *FakeFileBuilder) PDF(name string, sizeInKB int) *FakeFile
- func (b *FakeFileBuilder) Video(name string, sizeInKB int) *FakeFile
- func (b *FakeFileBuilder) XML(name string) *FakeFile
- type FakeStorage
- func (f *FakeStorage) AllDirectories(directory string) ([]string, error)
- func (f *FakeStorage) AllFiles(directory string) ([]string, error)
- func (f *FakeStorage) Assert(t testing.TB) *StorageAssertions
- func (f *FakeStorage) Clear()
- func (f *FakeStorage) Copy(from, to string) error
- func (f *FakeStorage) Delete(paths ...string) error
- func (f *FakeStorage) DeleteDirectory(directory string) error
- func (f *FakeStorage) Directories(directory string) ([]string, error)
- func (f *FakeStorage) Exists(path string) bool
- func (f *FakeStorage) Files(directory string) ([]string, error)
- func (f *FakeStorage) Get(path string) ([]byte, error)
- func (f *FakeStorage) GetAssertions() []assertion
- func (f *FakeStorage) GetStoredFiles() map[string][]byte
- func (f *FakeStorage) GetStream(path string) (io.ReadCloser, error)
- func (f *FakeStorage) LastModified(path string) (time.Time, error)
- func (f *FakeStorage) MakeDirectory(path string) error
- func (f *FakeStorage) MimeType(path string) (string, error)
- func (f *FakeStorage) Move(from, to string) error
- func (f *FakeStorage) Put(path string, contents []byte) error
- func (f *FakeStorage) PutStream(path string, stream io.Reader) error
- func (f *FakeStorage) ShouldFail(message string)
- func (f *FakeStorage) ShouldSucceed()
- func (f *FakeStorage) Size(path string) (int64, error)
- func (f *FakeStorage) TemporaryURL(path string, expiration time.Duration) (string, error)
- func (f *FakeStorage) URL(path string) string
- type StorageAssertions
- func (a *StorageAssertions) AssertContains(path string, substring string)
- func (a *StorageAssertions) AssertCopied(from, to string)
- func (a *StorageAssertions) AssertCount(expectedCount int)
- func (a *StorageAssertions) AssertDeleted(paths ...string)
- func (a *StorageAssertions) AssertDirectory(directory string, expectedFiles []string)
- func (a *StorageAssertions) AssertDirectoryEmpty(directory string)
- func (a *StorageAssertions) AssertDirectoryNotEmpty(directory string)
- func (a *StorageAssertions) AssertExists(path string)
- func (a *StorageAssertions) AssertLastOperation(expectedOperation string)
- func (a *StorageAssertions) AssertMimeType(path string, expectedMimeType string)
- func (a *StorageAssertions) AssertMissing(path string)
- func (a *StorageAssertions) AssertMoved(from, to string)
- func (a *StorageAssertions) AssertNotContains(path string, substring string)
- func (a *StorageAssertions) AssertNothingStored()
- func (a *StorageAssertions) AssertOperationCalled(operation string, path string)
- func (a *StorageAssertions) AssertOperationCount(operation string, expectedCount int)
- func (a *StorageAssertions) AssertSize(path string, expectedSize int64)
- func (a *StorageAssertions) AssertStored(path string, expectedContent []byte)
- func (a *StorageAssertions) AssertStoredString(path string, expectedContent string)
- func (a *StorageAssertions) AssertTemporaryURL(path string)
- func (a *StorageAssertions) AssertURL(path string, expectedURL string)
- func (a *StorageAssertions) DumpOperations()
- func (a *StorageAssertions) DumpStoredFiles()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeFile ¶
type FakeFile struct {
// contains filtered or unexported fields
}
FakeFile represents a fake file for testing
type FakeFileBuilder ¶
type FakeFileBuilder struct{}
FakeFileBuilder helps build fake files for testing
func (*FakeFileBuilder) Archive ¶
func (b *FakeFileBuilder) Archive(name string, sizeInKB int) *FakeFile
Archive creates a fake archive file (ZIP)
func (*FakeFileBuilder) CSV ¶
func (b *FakeFileBuilder) CSV(name string, rows int) *FakeFile
CSV creates a fake CSV file
func (*FakeFileBuilder) Create ¶
func (b *FakeFileBuilder) Create(name string, sizeInKB int) *FakeFile
Create creates a fake file with specified size in KB
func (*FakeFileBuilder) CreateWithMimeType ¶
func (b *FakeFileBuilder) CreateWithMimeType(name string, sizeInKB int, mimeType string) *FakeFile
CreateWithMimeType creates a fake file with specified size and MIME type
func (*FakeFileBuilder) Image ¶
func (b *FakeFileBuilder) Image(name string, width, height int) *FakeFile
Image creates a fake image file with specified dimensions
func (*FakeFileBuilder) JSON ¶
func (b *FakeFileBuilder) JSON(name string, data interface{}) *FakeFile
JSON creates a fake JSON file
func (*FakeFileBuilder) PDF ¶
func (b *FakeFileBuilder) PDF(name string, sizeInKB int) *FakeFile
PDF creates a fake PDF file
func (*FakeFileBuilder) Video ¶
func (b *FakeFileBuilder) Video(name string, sizeInKB int) *FakeFile
Video creates a fake video file (minimal valid MP4 structure)
func (*FakeFileBuilder) XML ¶
func (b *FakeFileBuilder) XML(name string) *FakeFile
XML creates a fake XML file
type FakeStorage ¶
type FakeStorage struct {
// contains filtered or unexported fields
}
FakeStorage is a fake storage driver for testing
func StorageFake ¶
func StorageFake() *FakeStorage
StorageFake creates a new fake storage instance for testing
func (*FakeStorage) AllDirectories ¶
func (f *FakeStorage) AllDirectories(directory string) ([]string, error)
AllDirectories lists all directories recursively
func (*FakeStorage) AllFiles ¶
func (f *FakeStorage) AllFiles(directory string) ([]string, error)
AllFiles lists all files recursively in a directory
func (*FakeStorage) Assert ¶
func (f *FakeStorage) Assert(t testing.TB) *StorageAssertions
Assert returns assertions for the fake storage
func (*FakeStorage) Clear ¶
func (f *FakeStorage) Clear()
Clear clears all stored files and assertions
func (*FakeStorage) Copy ¶
func (f *FakeStorage) Copy(from, to string) error
Copy copies a file from one path to another
func (*FakeStorage) Delete ¶
func (f *FakeStorage) Delete(paths ...string) error
Delete removes files at the given paths
func (*FakeStorage) DeleteDirectory ¶
func (f *FakeStorage) DeleteDirectory(directory string) error
DeleteDirectory deletes a directory and all its contents
func (*FakeStorage) Directories ¶
func (f *FakeStorage) Directories(directory string) ([]string, error)
Directories lists directories
func (*FakeStorage) Exists ¶
func (f *FakeStorage) Exists(path string) bool
Exists checks if a file exists at the given path
func (*FakeStorage) Files ¶
func (f *FakeStorage) Files(directory string) ([]string, error)
Files lists files in a directory
func (*FakeStorage) Get ¶
func (f *FakeStorage) Get(path string) ([]byte, error)
Get retrieves content from the given path
func (*FakeStorage) GetAssertions ¶
func (f *FakeStorage) GetAssertions() []assertion
GetAssertions returns all recorded assertions
func (*FakeStorage) GetStoredFiles ¶
func (f *FakeStorage) GetStoredFiles() map[string][]byte
GetStoredFiles returns a map of all stored files
func (*FakeStorage) GetStream ¶
func (f *FakeStorage) GetStream(path string) (io.ReadCloser, error)
GetStream retrieves a stream from the given path
func (*FakeStorage) LastModified ¶
func (f *FakeStorage) LastModified(path string) (time.Time, error)
LastModified returns the last modified time of a file
func (*FakeStorage) MakeDirectory ¶
func (f *FakeStorage) MakeDirectory(path string) error
MakeDirectory creates a directory (no-op for fake storage)
func (*FakeStorage) MimeType ¶
func (f *FakeStorage) MimeType(path string) (string, error)
MimeType returns the MIME type of a file
func (*FakeStorage) Move ¶
func (f *FakeStorage) Move(from, to string) error
Move moves a file from one path to another
func (*FakeStorage) Put ¶
func (f *FakeStorage) Put(path string, contents []byte) error
Put stores content at the given path
func (*FakeStorage) PutStream ¶
func (f *FakeStorage) PutStream(path string, stream io.Reader) error
PutStream stores a stream at the given path
func (*FakeStorage) ShouldFail ¶
func (f *FakeStorage) ShouldFail(message string)
ShouldFail configures the fake to fail with a specific message
func (*FakeStorage) ShouldSucceed ¶
func (f *FakeStorage) ShouldSucceed()
ShouldSucceed configures the fake to succeed
func (*FakeStorage) Size ¶
func (f *FakeStorage) Size(path string) (int64, error)
Size returns the size of a file at the given path
func (*FakeStorage) TemporaryURL ¶
TemporaryURL returns a temporary URL for a file
func (*FakeStorage) URL ¶
func (f *FakeStorage) URL(path string) string
URL returns the public URL for a file
type StorageAssertions ¶
type StorageAssertions struct {
// contains filtered or unexported fields
}
StorageAssertions provides assertion methods for storage testing
func NewStorageAssertions ¶
func NewStorageAssertions(storage *FakeStorage, t testing.TB) *StorageAssertions
NewStorageAssertions creates a new storage assertions instance
func (*StorageAssertions) AssertContains ¶
func (a *StorageAssertions) AssertContains(path string, substring string)
AssertContains verifies that a file contains specific text
func (*StorageAssertions) AssertCopied ¶
func (a *StorageAssertions) AssertCopied(from, to string)
AssertCopied verifies that a file was copied from one path to another
func (*StorageAssertions) AssertCount ¶
func (a *StorageAssertions) AssertCount(expectedCount int)
AssertCount verifies the number of stored files
func (*StorageAssertions) AssertDeleted ¶
func (a *StorageAssertions) AssertDeleted(paths ...string)
AssertDeleted verifies that files were deleted
func (*StorageAssertions) AssertDirectory ¶
func (a *StorageAssertions) AssertDirectory(directory string, expectedFiles []string)
AssertDirectory verifies that a directory contains specific files
func (*StorageAssertions) AssertDirectoryEmpty ¶
func (a *StorageAssertions) AssertDirectoryEmpty(directory string)
AssertDirectoryEmpty verifies that a directory is empty
func (*StorageAssertions) AssertDirectoryNotEmpty ¶
func (a *StorageAssertions) AssertDirectoryNotEmpty(directory string)
AssertDirectoryNotEmpty verifies that a directory is not empty
func (*StorageAssertions) AssertExists ¶
func (a *StorageAssertions) AssertExists(path string)
AssertExists verifies that a file exists at the given path
func (*StorageAssertions) AssertLastOperation ¶
func (a *StorageAssertions) AssertLastOperation(expectedOperation string)
AssertLastOperation verifies the last operation performed
func (*StorageAssertions) AssertMimeType ¶
func (a *StorageAssertions) AssertMimeType(path string, expectedMimeType string)
AssertMimeType verifies the MIME type of a stored file
func (*StorageAssertions) AssertMissing ¶
func (a *StorageAssertions) AssertMissing(path string)
AssertMissing verifies that a file does not exist at the given path
func (*StorageAssertions) AssertMoved ¶
func (a *StorageAssertions) AssertMoved(from, to string)
AssertMoved verifies that a file was moved from one path to another
func (*StorageAssertions) AssertNotContains ¶
func (a *StorageAssertions) AssertNotContains(path string, substring string)
AssertNotContains verifies that a file does not contain specific text
func (*StorageAssertions) AssertNothingStored ¶
func (a *StorageAssertions) AssertNothingStored()
AssertNothingStored verifies that no files were stored
func (*StorageAssertions) AssertOperationCalled ¶
func (a *StorageAssertions) AssertOperationCalled(operation string, path string)
AssertOperationCalled verifies that a specific operation was called
func (*StorageAssertions) AssertOperationCount ¶
func (a *StorageAssertions) AssertOperationCount(operation string, expectedCount int)
AssertOperationCount verifies the number of times an operation was called
func (*StorageAssertions) AssertSize ¶
func (a *StorageAssertions) AssertSize(path string, expectedSize int64)
AssertSize verifies the size of a stored file
func (*StorageAssertions) AssertStored ¶
func (a *StorageAssertions) AssertStored(path string, expectedContent []byte)
AssertStored verifies that a file was stored with specific content
func (*StorageAssertions) AssertStoredString ¶
func (a *StorageAssertions) AssertStoredString(path string, expectedContent string)
AssertStoredString verifies that a file was stored with specific string content
func (*StorageAssertions) AssertTemporaryURL ¶
func (a *StorageAssertions) AssertTemporaryURL(path string)
AssertTemporaryURL verifies that a temporary URL can be generated
func (*StorageAssertions) AssertURL ¶
func (a *StorageAssertions) AssertURL(path string, expectedURL string)
AssertURL verifies that a file has a specific URL
func (*StorageAssertions) DumpOperations ¶
func (a *StorageAssertions) DumpOperations()
DumpOperations logs all operations for debugging
func (*StorageAssertions) DumpStoredFiles ¶
func (a *StorageAssertions) DumpStoredFiles()
DumpStoredFiles logs all stored files for debugging