Documentation
¶
Index ¶
- func AwaitPortClosed(port int, timeout time.Duration) error
- func BuildGoBinary(binaryName, packagePath string) (string, error)
- func BuildGoBinaryOnDemand(env, binaryName, packagePath string) (string, error)
- func CheckIfOllamaReady(modelName string) error
- func FindProjectRoot() string
- func GetOllamaModel(model OllamaModel) (string, error)
- func RequireEventuallyNoError(t testing.TB, condition func() error, waitFor time.Duration, ...)
- func RequireRandomPorts(t testing.TB, count int) []int
- type CredentialsContext
- type NewControllerEventChanImpl
- type OllamaModel
- type OutBuffer
- type OutBuffers
- type RequiredCredential
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AwaitPortClosed ¶ added in v0.4.0
AwaitPortClosed waits until the port is no longer listening.
func BuildGoBinary ¶ added in v0.4.0
BuildGoBinary builds a Go binary with the given name and package path.
func BuildGoBinaryOnDemand ¶ added in v0.4.0
BuildGoBinaryOnDemand builds the extproc binary unless EXTPROC_BIN is set. If EXTPROC_BIN environment variable is set, it will use that path instead.
func CheckIfOllamaReady ¶ added in v0.4.0
CheckIfOllamaReady verifies if Ollama server is ready and the model is available. Returns an error if Ollama is not reachable or the model is not available.
func FindProjectRoot ¶ added in v0.4.0
func FindProjectRoot() string
FindProjectRoot finds the root of the project by looking for go.mod.
func GetOllamaModel ¶ added in v0.4.0
func GetOllamaModel(model OllamaModel) (string, error)
GetOllamaModel reads the specified model from .env.ollama relative to the project root. Returns an error if the file is missing or the model is not found.
func RequireEventuallyNoError ¶ added in v0.4.0
func RequireEventuallyNoError(t testing.TB, condition func() error, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}, )
RequireEventuallyNoError repeatedly calls condition until it returns nil or times out. The last error is included in the failure message along with msgAndArgs.
Types ¶
type CredentialsContext ¶ added in v0.2.0
type CredentialsContext struct {
// OpenAIValid, AWSValid, AzureValid, etc. are true if the credentials are set and ready to use the real services.
OpenAIValid, AWSValid, AzureValid, GeminiValid, GroqValid, GrokValid, SambaNovaValid, DeepInfraValid, AnthropicValid, CohereValid bool
// OpenAIAPIKey is the OpenAI API key. This defaults to "dummy-openai-api-key" if not set.
OpenAIAPIKey string
// AnthropicAPIKey is the Anthropic API key. This defaults to "dummy-anthropic-api-key" if not set.
AnthropicAPIKey string
// CohereAPIKey is the Cohere API key. This defaults to "dummy-cohere-api-key" if not set.
CohereAPIKey string
// AWSFileLiteral contains the AWS credentials in the format of a file literal.
AWSFileLiteral string
AWSAccessKeyID string
AWSSecretAccessKey string
// AzureAccessToken is the Azure access token. This defaults to "dummy-azure-access-token" if not set.
AzureAccessToken string
// GeminiAPIKey is the API key for Gemini API. https://ai.google.dev/gemini-api/docs/openai
GeminiAPIKey string
// GroqAPIKey is the API key for Groq API. https://console.groq.com/docs/openai
GroqAPIKey string
// GrokAPIKey is the API key for Grok API. https://console.grok.com/docs/openai
GrokAPIKey string
// SambaNovaAPIKey is the API key for SambaNova API. https://docs.sambanova.ai/cloud/api-reference/endpoints/chat
SambaNovaAPIKey string
// DeepInfraAPIKey is the API key for DeepInfra API. https://deepinfra.com/docs/openai_api
DeepInfraAPIKey string
}
CredentialsContext holds the context for the credentials used in the tests.
func RequireNewCredentialsContext ¶ added in v0.2.0
func RequireNewCredentialsContext() (ctx CredentialsContext)
RequireNewCredentialsContext creates a new credential context for the tests from the environment variables.
func (CredentialsContext) MaybeSkip ¶ added in v0.2.0
func (c CredentialsContext) MaybeSkip(t testing.TB, required RequiredCredential)
MaybeSkip skips the test if the required credentials are not set.
type NewControllerEventChanImpl ¶ added in v0.2.0
type NewControllerEventChanImpl[T client.Object] struct { Ch chan event.GenericEvent }
NewControllerEventChanImpl is a test implementation of the controller event channels that are used in the cross-controller communication.
func NewControllerEventChan ¶ added in v0.2.0
func NewControllerEventChan[T client.Object]() *NewControllerEventChanImpl[T]
NewControllerEventChan creates a new SyncFnImpl.
func (*NewControllerEventChanImpl[T]) RequireItemsEventually ¶ added in v0.2.0
func (s *NewControllerEventChanImpl[T]) RequireItemsEventually(t testing.TB, exp int) []T
RequireItemsEventually returns a copy of the items.
type OllamaModel ¶ added in v0.4.0
type OllamaModel int
OllamaModel represents the different model types defined in .env.ollama.
const ( ChatModel OllamaModel = iota ThinkingModel CompletionModel EmbeddingsModel )
func (OllamaModel) String ¶ added in v0.4.0
func (m OllamaModel) String() string
String returns the environment variable name for this model type.
type OutBuffers ¶ added in v0.4.0
type OutBuffers []OutBuffer
OutBuffers allows you to reset all the buffers easily.
func CaptureOutput ¶ added in v0.4.0
func CaptureOutput(labels ...string) OutBuffers
CaptureOutput creates labeled log capture writers in the same order as labels.
func DumpLogsOnFail ¶ added in v0.4.0
func DumpLogsOnFail(t testing.TB, labels ...string) OutBuffers
DumpLogsOnFail creates labeled log capture writers that dump only on test failure. Returns WriterStringers in the same order as labels.
func (OutBuffers) Reset ¶ added in v0.4.0
func (s OutBuffers) Reset()
type RequiredCredential ¶ added in v0.2.0
type RequiredCredential uint64
RequiredCredential is a bit flag for the required credentials.
const ( // RequiredCredentialOpenAI is the bit flag for the OpenAI API key. RequiredCredentialOpenAI RequiredCredential = 1 << iota // RequiredCredentialAWS is the bit flag for the AWS credentials. RequiredCredentialAWS // RequiredCredentialAzure is the bit flag for the Azure access token. RequiredCredentialAzure // RequiredCredentialGemini is the bit flag for the Gemini API key. RequiredCredentialGemini // RequiredCredentialGroq is the bit flag for the Groq API key. // https://console.groq.com/docs/openai RequiredCredentialGroq // RequiredCredentialGrok is the bit flag for the Grok API key. // https://console.groq.com/docs/openai RequiredCredentialGrok // RequiredCredentialSambaNova is the bit flag for the SambaNova API key. // https://docs.sambanova.ai/cloud/api-reference/endpoints/chat RequiredCredentialSambaNova // RequiredCredentialDeepInfra is the bit flag for the DeepInfra API key. // https://deepinfra.com/docs/openai_api RequiredCredentialDeepInfra // RequiredCredentialAnthropic is the bit flag for the Anthropic API key. RequiredCredentialAnthropic // RequiredCredentialCohere is the bit flag for the Cohere API key. RequiredCredentialCohere )