Documentation
¶
Overview ¶
Package testutil provides mock implementations and testing utilities for the AI Provider Kit. These mocks are used across the codebase to facilitate unit and integration testing.
Index ¶
- type MockAuthenticator
- func (m *MockAuthenticator) Authenticate(ctx context.Context, config types.AuthConfig) error
- func (m *MockAuthenticator) GetAuthMethod() types.AuthMethod
- func (m *MockAuthenticator) GetToken() (string, error)
- func (m *MockAuthenticator) IsAuthenticated() bool
- func (m *MockAuthenticator) Logout(ctx context.Context) error
- func (m *MockAuthenticator) RefreshToken(ctx context.Context) error
- func (m *MockAuthenticator) SetAuthenticated(authenticated bool)
- func (m *MockAuthenticator) SetLogoutError(err error)
- func (m *MockAuthenticator) SetRefreshError(err error)
- type MockProvider
- func (m *MockProvider) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
- func (m *MockProvider) Configure(config types.ProviderConfig) error
- func (m *MockProvider) Description() string
- func (m *MockProvider) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
- func (m *MockProvider) GetConfig() types.ProviderConfig
- func (m *MockProvider) GetDefaultModel() string
- func (m *MockProvider) GetMetrics() types.ProviderMetrics
- func (m *MockProvider) GetModels(ctx context.Context) ([]types.Model, error)
- func (m *MockProvider) GetToolFormat() types.ToolFormat
- func (m *MockProvider) HealthCheck(ctx context.Context) error
- func (m *MockProvider) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
- func (m *MockProvider) IsAuthenticated() bool
- func (m *MockProvider) Logout(ctx context.Context) error
- func (m *MockProvider) Name() string
- func (m *MockProvider) SetDescription(description string)
- func (m *MockProvider) SetHealthy(healthy bool, err error)
- func (m *MockProvider) SetModels(models []types.Model)
- func (m *MockProvider) SupportsResponsesAPI() bool
- func (m *MockProvider) SupportsStreaming() bool
- func (m *MockProvider) SupportsToolCalling() bool
- func (m *MockProvider) Type() types.ProviderType
- type MockStream
- type MockTokenStorage
- func (m *MockTokenStorage) CleanupExpired() error
- func (m *MockTokenStorage) DeleteToken(key string) error
- func (m *MockTokenStorage) IsTokenValid(key string) bool
- func (m *MockTokenStorage) ListTokens() ([]string, error)
- func (m *MockTokenStorage) RetrieveToken(key string) (*types.OAuthConfig, error)
- func (m *MockTokenStorage) SetCleanupError(err error)
- func (m *MockTokenStorage) SetDeleteError(err error)
- func (m *MockTokenStorage) StoreToken(key string, config *types.OAuthConfig) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockAuthenticator ¶ added in v1.0.55
type MockAuthenticator struct {
// contains filtered or unexported fields
}
MockAuthenticator is a mock implementation of Authenticator for testing.
func NewMockAuthenticator ¶ added in v1.0.55
func NewMockAuthenticator() *MockAuthenticator
NewMockAuthenticator creates a new MockAuthenticator with default values.
func (*MockAuthenticator) Authenticate ¶ added in v1.0.55
func (m *MockAuthenticator) Authenticate(ctx context.Context, config types.AuthConfig) error
Authenticate authenticates using the mock authenticator.
func (*MockAuthenticator) GetAuthMethod ¶ added in v1.0.55
func (m *MockAuthenticator) GetAuthMethod() types.AuthMethod
GetAuthMethod returns the authentication method used by the mock authenticator.
func (*MockAuthenticator) GetToken ¶ added in v1.0.55
func (m *MockAuthenticator) GetToken() (string, error)
GetToken returns the authentication token from the mock authenticator.
func (*MockAuthenticator) IsAuthenticated ¶ added in v1.0.55
func (m *MockAuthenticator) IsAuthenticated() bool
IsAuthenticated returns whether the mock authenticator is authenticated.
func (*MockAuthenticator) Logout ¶ added in v1.0.55
func (m *MockAuthenticator) Logout(ctx context.Context) error
Logout logs out the mock authenticator.
func (*MockAuthenticator) RefreshToken ¶ added in v1.0.55
func (m *MockAuthenticator) RefreshToken(ctx context.Context) error
RefreshToken refreshes the authentication token.
func (*MockAuthenticator) SetAuthenticated ¶ added in v1.0.55
func (m *MockAuthenticator) SetAuthenticated(authenticated bool)
SetAuthenticated sets the authenticated state of the mock authenticator.
func (*MockAuthenticator) SetLogoutError ¶ added in v1.0.55
func (m *MockAuthenticator) SetLogoutError(err error)
SetLogoutError configures the mock to fail on logout with the given error.
func (*MockAuthenticator) SetRefreshError ¶ added in v1.0.55
func (m *MockAuthenticator) SetRefreshError(err error)
SetRefreshError configures the mock to fail on token refresh with the given error.
type MockProvider ¶ added in v1.0.55
type MockProvider struct {
// contains filtered or unexported fields
}
MockProvider is a comprehensive mock implementation of types.Provider for testing. It combines features from multiple test implementations to provide a flexible testing tool.
func NewMockProvider ¶ added in v1.0.55
func NewMockProvider(name string, providerType types.ProviderType) *MockProvider
NewMockProvider creates a new MockProvider with sensible defaults.
func (*MockProvider) Authenticate ¶ added in v1.0.55
func (m *MockProvider) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
Authenticate authenticates the mock provider with the given configuration.
func (*MockProvider) Configure ¶ added in v1.0.55
func (m *MockProvider) Configure(config types.ProviderConfig) error
Configure configures the mock provider with the given configuration.
func (*MockProvider) Description ¶ added in v1.0.55
func (m *MockProvider) Description() string
Description returns the description of the mock provider.
func (*MockProvider) GenerateChatCompletion ¶ added in v1.0.55
func (m *MockProvider) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
GenerateChatCompletion generates a mock chat completion stream.
func (*MockProvider) GetConfig ¶ added in v1.0.55
func (m *MockProvider) GetConfig() types.ProviderConfig
GetConfig returns the configuration of the mock provider.
func (*MockProvider) GetDefaultModel ¶ added in v1.0.55
func (m *MockProvider) GetDefaultModel() string
GetDefaultModel returns the default model for the mock provider.
func (*MockProvider) GetMetrics ¶ added in v1.0.55
func (m *MockProvider) GetMetrics() types.ProviderMetrics
GetMetrics returns the metrics for the mock provider.
func (*MockProvider) GetModels ¶ added in v1.0.55
GetModels returns the list of models supported by the mock provider.
func (*MockProvider) GetToolFormat ¶ added in v1.0.55
func (m *MockProvider) GetToolFormat() types.ToolFormat
GetToolFormat returns the tool format supported by the mock provider.
func (*MockProvider) HealthCheck ¶ added in v1.0.55
func (m *MockProvider) HealthCheck(ctx context.Context) error
HealthCheck performs a health check on the mock provider.
func (*MockProvider) InvokeServerTool ¶ added in v1.0.55
func (m *MockProvider) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
InvokeServerTool invokes a server tool (not implemented in mock).
func (*MockProvider) IsAuthenticated ¶ added in v1.0.55
func (m *MockProvider) IsAuthenticated() bool
IsAuthenticated returns whether the mock provider is authenticated.
func (*MockProvider) Logout ¶ added in v1.0.55
func (m *MockProvider) Logout(ctx context.Context) error
Logout logs out the mock provider.
func (*MockProvider) Name ¶ added in v1.0.55
func (m *MockProvider) Name() string
Name returns the name of the mock provider.
func (*MockProvider) SetDescription ¶ added in v1.0.55
func (m *MockProvider) SetDescription(description string)
SetDescription allows setting a custom description.
func (*MockProvider) SetHealthy ¶ added in v1.0.55
func (m *MockProvider) SetHealthy(healthy bool, err error)
SetHealthy allows setting the health status of the mock provider.
func (*MockProvider) SetModels ¶ added in v1.0.55
func (m *MockProvider) SetModels(models []types.Model)
SetModels allows setting custom models for the mock provider.
func (*MockProvider) SupportsResponsesAPI ¶ added in v1.0.55
func (m *MockProvider) SupportsResponsesAPI() bool
SupportsResponsesAPI returns whether the mock provider supports the responses API.
func (*MockProvider) SupportsStreaming ¶ added in v1.0.55
func (m *MockProvider) SupportsStreaming() bool
SupportsStreaming returns whether the mock provider supports streaming.
func (*MockProvider) SupportsToolCalling ¶ added in v1.0.55
func (m *MockProvider) SupportsToolCalling() bool
SupportsToolCalling returns whether the mock provider supports tool calling.
func (*MockProvider) Type ¶ added in v1.0.55
func (m *MockProvider) Type() types.ProviderType
Type returns the provider type of the mock provider.
type MockStream ¶ added in v1.0.55
type MockStream struct {
// contains filtered or unexported fields
}
MockStream is a mock implementation of types.ChatCompletionStream for testing.
func NewMockStream ¶ added in v1.0.55
func NewMockStream() *MockStream
NewMockStream creates a new MockStream with default behavior.
func NewMockStreamWithChunks ¶ added in v1.0.55
func NewMockStreamWithChunks(chunks []types.ChatCompletionChunk) *MockStream
NewMockStreamWithChunks creates a new MockStream with custom chunks.
func (*MockStream) Close ¶ added in v1.0.55
func (m *MockStream) Close() error
Close closes the mock stream.
func (*MockStream) IsClosed ¶ added in v1.0.55
func (m *MockStream) IsClosed() bool
IsClosed returns whether the stream has been closed.
func (*MockStream) Next ¶ added in v1.0.55
func (m *MockStream) Next() (types.ChatCompletionChunk, error)
Next returns the next chunk in the mock stream.
type MockTokenStorage ¶ added in v1.0.55
type MockTokenStorage struct {
// contains filtered or unexported fields
}
MockTokenStorage is a mock implementation of TokenStorage for testing.
func NewMockTokenStorage ¶ added in v1.0.55
func NewMockTokenStorage() *MockTokenStorage
NewMockTokenStorage creates a new MockTokenStorage.
func (*MockTokenStorage) CleanupExpired ¶ added in v1.0.55
func (m *MockTokenStorage) CleanupExpired() error
CleanupExpired cleans up expired tokens from the mock token storage.
func (*MockTokenStorage) DeleteToken ¶ added in v1.0.55
func (m *MockTokenStorage) DeleteToken(key string) error
DeleteToken deletes a token from the mock token storage.
func (*MockTokenStorage) IsTokenValid ¶ added in v1.0.55
func (m *MockTokenStorage) IsTokenValid(key string) bool
IsTokenValid checks if a token is valid in the mock token storage.
func (*MockTokenStorage) ListTokens ¶ added in v1.0.55
func (m *MockTokenStorage) ListTokens() ([]string, error)
ListTokens lists all tokens in the mock token storage.
func (*MockTokenStorage) RetrieveToken ¶ added in v1.0.55
func (m *MockTokenStorage) RetrieveToken(key string) (*types.OAuthConfig, error)
RetrieveToken retrieves a token from the mock token storage.
func (*MockTokenStorage) SetCleanupError ¶ added in v1.0.55
func (m *MockTokenStorage) SetCleanupError(err error)
SetCleanupError configures the mock to fail on cleanup with the given error.
func (*MockTokenStorage) SetDeleteError ¶ added in v1.0.55
func (m *MockTokenStorage) SetDeleteError(err error)
SetDeleteError configures the mock to fail on delete with the given error.
func (*MockTokenStorage) StoreToken ¶ added in v1.0.55
func (m *MockTokenStorage) StoreToken(key string, config *types.OAuthConfig) error
StoreToken stores a token in the mock token storage.