testutil

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertFileContains

func AssertFileContains(t *testing.T, path string, substring string)

AssertFileContains checks if a file contains a substring

func AssertFileContent

func AssertFileContent(t *testing.T, path string, expected []byte)

AssertFileContent checks if a file has expected content

func AssertFileExists

func AssertFileExists(t *testing.T, path string)

AssertFileExists checks if a file exists

func AssertFileNotExists

func AssertFileNotExists(t *testing.T, path string)

AssertFileNotExists checks if a file does not exist

func CaptureOutput

func CaptureOutput(t *testing.T, f func()) (stdout, stderr string)

CaptureOutput captures stdout/stderr during test execution

func CompareDirectories

func CompareDirectories(t *testing.T, dir1, dir2 string)

CompareDirectories compares two directories recursively

func CreateTestDirectory

func CreateTestDirectory(t *testing.T) string

CreateTestDirectory creates a temporary directory structure for testing

func CreateTestFile

func CreateTestFile(t *testing.T, path string, content []byte)

CreateTestFile creates a test file with content

func CreateTestWordDirectory

func CreateTestWordDirectory(t *testing.T, baseDir, word string) string

CreateTestWordDirectory creates a test word directory with standard files

Types

type MockFileSystem

type MockFileSystem struct {
	Files  map[string][]byte
	Errors map[string]error
	Calls  []string
}

MockFileSystem mocks file system operations

func (*MockFileSystem) Exists

func (m *MockFileSystem) Exists(path string) bool

Exists mocks checking if a file exists

func (*MockFileSystem) ReadFile

func (m *MockFileSystem) ReadFile(path string) ([]byte, error)

ReadFile mocks reading a file

func (*MockFileSystem) WriteFile

func (m *MockFileSystem) WriteFile(path string, data []byte) error

WriteFile mocks writing a file

type MockHTTPClient

type MockHTTPClient struct {
	Responses map[string]*MockResponse
	Errors    map[string]error
	Calls     []string
}

MockHTTPClient mocks HTTP client for testing

func (*MockHTTPClient) Get

func (m *MockHTTPClient) Get(url string) (*MockResponse, error)

Get mocks an HTTP GET request

func (*MockHTTPClient) Post

func (m *MockHTTPClient) Post(url string, body interface{}) (*MockResponse, error)

Post mocks an HTTP POST request

type MockOpenAIClient

type MockOpenAIClient struct {
	TTSResponses   map[string][]byte
	ImageResponses map[string]string
	Errors         map[string]error
	Calls          []string
}

MockOpenAIClient mocks OpenAI API client

func (*MockOpenAIClient) CreateImage

func (m *MockOpenAIClient) CreateImage(ctx context.Context, prompt string) (string, error)

CreateImage mocks OpenAI DALL-E API

func (*MockOpenAIClient) CreateSpeech

func (m *MockOpenAIClient) CreateSpeech(ctx context.Context, text, voice, model string) (io.ReadCloser, error)

CreateSpeech mocks OpenAI TTS API

type MockResponse

type MockResponse struct {
	StatusCode int
	Body       string
	Headers    map[string]string
}

MockResponse represents a mocked HTTP response

type MockTranslator

type MockTranslator struct {
	Translations map[string]string
	Errors       map[string]error
	Calls        []string
}

MockTranslator mocks translation service

func (*MockTranslator) Translate

func (m *MockTranslator) Translate(ctx context.Context, text, fromLang, toLang string) (string, error)

Translate mocks translating text

type TestDataGenerator

type TestDataGenerator struct{}

TestDataGenerator generates test data

func (*TestDataGenerator) GenerateAudioData

func (g *TestDataGenerator) GenerateAudioData() []byte

GenerateAudioData generates mock audio data

func (*TestDataGenerator) GenerateBulgarianWord

func (g *TestDataGenerator) GenerateBulgarianWord() string

GenerateBulgarianWord generates a test Bulgarian word

func (*TestDataGenerator) GenerateImageData

func (g *TestDataGenerator) GenerateImageData() []byte

GenerateImageData generates mock image data

Jump to

Keyboard shortcuts

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