testutil

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertFileContent

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

AssertFileContent はファイル内容が期待通りであることを確認

func AssertFileExists

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

AssertFileExists はファイルが存在することを確認

func AssertFileNotExists

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

AssertFileNotExists はファイルが存在しないことを確認

func CreateTempFile

func CreateTempFile(t *testing.T, dir, name, content string) string

CreateTempFile は一時ファイルを作成するヘルパー

func FileExists added in v0.29.0

func FileExists(t *testing.T, path string) bool

FileExists はファイルが存在するかチェック(boolを返す)

func MockConfirm

func MockConfirm(result bool) func(string) bool

MockConfirm はconfirm()関数をモックするヘルパー

func ReadFile

func ReadFile(t *testing.T, path string) (string, error)

ReadFile はファイルを読み込むヘルパー

func SetupTempHome

func SetupTempHome(t *testing.T) string

SetupTempHome は一時的なHOMEディレクトリを設定するヘルパー

Types

type MockProvider added in v0.31.0

type MockProvider struct {
	// NameFunc allows customizing the Name() return value
	NameFunc func() string

	// SupportsImagesFunc allows customizing the SupportsImages() return value
	SupportsImagesFunc func() bool

	// ChatWithToolsFunc allows customizing the ChatWithTools() behavior
	ChatWithToolsFunc func(ctx context.Context, systemPrompt string, history []api.Message, model string) (string, error)

	// ChatWithImageFunc allows customizing the ChatWithImage() behavior
	ChatWithImageFunc func(ctx context.Context, systemPrompt string, history []api.Message, userMessage string, image *api.ImageData, model string) (string, error)

	// CallCount tracks how many times each method was called
	CallCount struct {
		Name           int
		SupportsImages int
		ChatWithTools  int
		ChatWithImage  int
	}

	// LastCall stores the arguments of the last call to each method
	LastCall struct {
		ChatWithTools struct {
			SystemPrompt string
			History      []api.Message
			Model        string
		}
		ChatWithImage struct {
			SystemPrompt string
			History      []api.Message
			UserMessage  string
			Image        *api.ImageData
			Model        string
		}
	}
}

MockProvider implements api.Provider for testing purposes

func NewMockProvider added in v0.31.0

func NewMockProvider() *MockProvider

NewMockProvider creates a new MockProvider with default settings

func NewMockProviderWithError added in v0.31.0

func NewMockProviderWithError(err error) *MockProvider

NewMockProviderWithError creates a new MockProvider that always returns an error

func NewMockProviderWithName added in v0.31.0

func NewMockProviderWithName(name string) *MockProvider

NewMockProviderWithName creates a new MockProvider with a custom name

func NewMockProviderWithResponse added in v0.31.0

func NewMockProviderWithResponse(response string) *MockProvider

NewMockProviderWithResponse creates a new MockProvider that returns a fixed response

func (*MockProvider) ChatWithImage added in v0.31.0

func (m *MockProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []api.Message, userMessage string, image *api.ImageData, model string) (string, error)

ChatWithImage sends a chat request with an image

func (*MockProvider) ChatWithTools added in v0.31.0

func (m *MockProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []api.Message, model string) (string, error)

ChatWithTools sends a chat request with tool support

func (*MockProvider) Name added in v0.31.0

func (m *MockProvider) Name() string

Name returns the provider name

func (*MockProvider) Reset added in v0.31.0

func (m *MockProvider) Reset()

Reset clears all call counts and last call data

func (*MockProvider) SupportsImages added in v0.31.0

func (m *MockProvider) SupportsImages() bool

SupportsImages returns whether the provider supports images

Jump to

Keyboard shortcuts

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