Documentation
¶
Index ¶
- func AssertFileContent(t *testing.T, path string, expected string)
- func AssertFileExists(t *testing.T, path string)
- func AssertFileNotExists(t *testing.T, path string)
- func CreateTempFile(t *testing.T, dir, name, content string) string
- func FileExists(t *testing.T, path string) bool
- func MockConfirm(result bool) func(string) bool
- func ReadFile(t *testing.T, path string) (string, error)
- func SetupTempHome(t *testing.T) string
- type MockProvider
- func (m *MockProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []api.Message, ...) (string, error)
- func (m *MockProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []api.Message, model string) (string, error)
- func (m *MockProvider) Name() string
- func (m *MockProvider) Reset()
- func (m *MockProvider) SupportsImages() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFileContent ¶
AssertFileContent はファイル内容が期待通りであることを確認
func AssertFileExists ¶
AssertFileExists はファイルが存在することを確認
func AssertFileNotExists ¶
AssertFileNotExists はファイルが存在しないことを確認
func CreateTempFile ¶
CreateTempFile は一時ファイルを作成するヘルパー
func FileExists ¶ added in v0.29.0
FileExists はファイルが存在するかチェック(boolを返す)
func MockConfirm ¶
MockConfirm はconfirm()関数をモックするヘルパー
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