testing

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

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

func (*FakeFile) Content

func (f *FakeFile) Content() []byte

Content returns the file content as bytes

func (*FakeFile) MimeType

func (f *FakeFile) MimeType() string

MimeType returns the MIME type of the file

func (*FakeFile) Name

func (f *FakeFile) Name() string

Name returns the file name

func (*FakeFile) Reader

func (f *FakeFile) Reader() io.Reader

Reader returns an io.Reader for the file content

func (*FakeFile) Size

func (f *FakeFile) Size() int64

Size returns the file size in bytes

func (*FakeFile) String

func (f *FakeFile) String() string

String returns the file content as a string

type FakeFileBuilder

type FakeFileBuilder struct{}

FakeFileBuilder helps build fake files for testing

func Fake

func Fake() *FakeFileBuilder

Fake returns a new FakeFileBuilder for creating test files

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

func (f *FakeStorage) TemporaryURL(path string, expiration time.Duration) (string, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL