testutil

package
v1.0.55 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 6 Imported by: 0

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

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

func (m *MockProvider) GetModels(ctx context.Context) ([]types.Model, error)

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

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.

Jump to

Keyboard shortcuts

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