Help us shape the future of Go! Take the 2026 Go Developer Survey

framework

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package framework provides testing framework utilities.

Index

Constants

View Source
const DefaultModel = "gemini-2.5-flash"

DefaultModel is the default Gemini model to use.

Variables

View Source
var (
	FindFreePort          = integration.FindFreePort
	NewManagedProcess     = integration.NewManagedProcess
	WaitForTCPPort        = integration.WaitForTCPPort
	GetProjectRoot        = integration.GetProjectRoot
	ServiceStartupTimeout = 15 * time.Second
)

Re-exporting these from the integration package so that framework users don't need to import both.

Functions

func BuildCachingServer

func BuildCachingServer(t *testing.T) *integration.ManagedProcess

BuildCachingServer builds and starts a caching server for testing.

func BuildEverythingServer

func BuildEverythingServer(t *testing.T) *integration.ManagedProcess

BuildEverythingServer builds a server with everything.

func BuildGRPCAuthedWeatherServer

func BuildGRPCAuthedWeatherServer(t *testing.T) *integration.ManagedProcess

BuildGRPCAuthedWeatherServer builds the authenticated gRPC weather server.

func BuildGRPCWeatherServer

func BuildGRPCWeatherServer(t *testing.T) *integration.ManagedProcess

BuildGRPCWeatherServer builds the gRPC weather server.

func BuildHTTPAuthedEchoServer

func BuildHTTPAuthedEchoServer(t *testing.T) *integration.ManagedProcess

BuildHTTPAuthedEchoServer builds the HTTP authed echo server for testing.

func BuildHTTPEchoServer

func BuildHTTPEchoServer(t *testing.T) *integration.ManagedProcess

BuildHTTPEchoServer builds and starts an HTTP echo server for testing.

func BuildOpenAPIAuthedServer

func BuildOpenAPIAuthedServer(t *testing.T) *integration.ManagedProcess

BuildOpenAPIAuthedServer builds the openapi authenticated server.

func BuildOpenAPIWeatherServer

func BuildOpenAPIWeatherServer(t *testing.T) *integration.ManagedProcess

BuildOpenAPIWeatherServer builds the openapi weather server.

func BuildStdioDockerServer

func BuildStdioDockerServer(_ *testing.T) *integration.ManagedProcess

BuildStdioDockerServer builds the stdio docker server (nop).

func BuildStdioServer

func BuildStdioServer(_ *testing.T) *integration.ManagedProcess

BuildStdioServer builds the stdio server (nop).

func BuildStreamableHTTPServer

func BuildStreamableHTTPServer(t *testing.T) *integration.ManagedProcess

BuildStreamableHTTPServer builds the streamable http server.

func BuildWebrtcWeatherServer

func BuildWebrtcWeatherServer(t *testing.T) *integration.ManagedProcess

BuildWebrtcWeatherServer builds the webrtc weather server.

func BuildWebsocketWeatherServer

func BuildWebsocketWeatherServer(t *testing.T) *integration.ManagedProcess

BuildWebsocketWeatherServer builds the websocket weather server.

func NoOpMiddleware

func NoOpMiddleware(_ *testing.T, next http.Handler) http.Handler

NoOpMiddleware is a middleware that does nothing and calls the next handler.

func RegisterCachingService

func RegisterCachingService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterCachingService registers the caching service with the MCP server.

func RegisterEverythingService

func RegisterEverythingService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterEverythingService registers everything service.

func RegisterGRPCAuthedWeatherService

func RegisterGRPCAuthedWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterGRPCAuthedWeatherService registers the authenticated gRPC weather service.

func RegisterGRPCWeatherService

func RegisterGRPCWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterGRPCWeatherService registers the gRPC weather service.

func RegisterHTTPAuthedEchoService

func RegisterHTTPAuthedEchoService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterHTTPAuthedEchoService registers the HTTP authed echo service with the given registration client.

func RegisterHTTPEchoService

func RegisterHTTPEchoService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterHTTPEchoService registers the HTTP echo service with the MCP server.

func RegisterOpenAPIAuthedService

func RegisterOpenAPIAuthedService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterOpenAPIAuthedService registers the openapi authenticated service.

func RegisterOpenAPIWeatherService

func RegisterOpenAPIWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterOpenAPIWeatherService registers the openapi weather service.

func RegisterStdioDockerService

func RegisterStdioDockerService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, _ string)

RegisterStdioDockerService registers the stdio docker service.

func RegisterStdioService

func RegisterStdioService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, _ string)

RegisterStdioService registers the stdio service.

func RegisterStreamableHTTPService

func RegisterStreamableHTTPService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterStreamableHTTPService registers the streamable http service.

func RegisterWebrtcWeatherService

func RegisterWebrtcWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterWebrtcWeatherService registers the webrtc weather service.

func RegisterWebsocketWeatherService

func RegisterWebsocketWeatherService(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)

RegisterWebsocketWeatherService registers the websocket weather service.

func RunE2ETest

func RunE2ETest(t *testing.T, testCase *E2ETestCase)

RunE2ETest runs an end-to-end test case.

func TestE2ECaching

func TestE2ECaching(t *testing.T)

TestE2ECaching tests the end-to-end caching functionality.

func ValidateCaching

func ValidateCaching(t *testing.T, mcpanyEndpoint, upstreamEndpoint string)

ValidateCaching validates that caching is working correctly.

func ValidateRegisteredTool

func ValidateRegisteredTool(t *testing.T, mcpanyEndpoint string, expectedTool *mcp.Tool)

ValidateRegisteredTool validates that the expected tool is registered.

func VerifyMCPClient

func VerifyMCPClient(t *testing.T, mcpanyEndpoint string)

VerifyMCPClient verifies the MCP client.

Types

type AITool

type AITool interface {
	Install()
	AddMCP(name, endpoint string)
	RemoveMCP(name string)
	Run(apiKey, model, prompt string) (string, error)
}

AITool represents an AI tool.

type E2ETestCase

type E2ETestCase struct {
	Name                         string
	UpstreamServiceType          string
	BuildUpstream                func(t *testing.T) *integration.ManagedProcess
	RegisterUpstream             func(t *testing.T, registrationClient apiv1.RegistrationServiceClient, upstreamEndpoint string)
	ValidateTool                 func(t *testing.T, mcpanyEndpoint string)
	ValidateMiddlewares          func(t *testing.T, mcpanyEndpoint string, upstreamEndpoint string)
	InvokeAIClient               func(t *testing.T, mcpanyEndpoint string)
	InvokeAIClientWithServerInfo func(t *testing.T, serverInfo *integration.MCPANYTestServerInfo)
	RegistrationMethods          []RegistrationMethod
	GenerateUpstreamConfig       func(_ string) string
	StartMCPANYServer            func(t *testing.T, testName string, extraArgs ...string) *integration.MCPANYTestServerInfo
	RegisterUpstreamWithJSONRPC  func(t *testing.T, mcpanyEndpoint, upstreamEndpoint string)
}

E2ETestCase defines the structure for an end-to-end test case.

type GeminiCLI

type GeminiCLI struct {
	// contains filtered or unexported fields
}

GeminiCLI handles interactions with the Gemini CLI tool for testing.

func NewGeminiCLI

func NewGeminiCLI(t *testing.T) *GeminiCLI

NewGeminiCLI creates a new GeminiCLI instance.

func (*GeminiCLI) AddMCP

func (g *GeminiCLI) AddMCP(name, endpoint string)

AddMCP adds an MCP server to the Gemini CLI configuration.

func (*GeminiCLI) Install

func (g *GeminiCLI) Install()

Install installs the Gemini CLI tool.

func (*GeminiCLI) RemoveMCP

func (g *GeminiCLI) RemoveMCP(name string)

RemoveMCP removes an MCP server from the Gemini CLI configuration.

func (*GeminiCLI) Run

func (g *GeminiCLI) Run(apiKey, prompt string) (string, error)

Run executes a prompt against the Gemini CLI using the provided API key.

type RegistrationMethod

type RegistrationMethod string

RegistrationMethod defines the method used to register an upstream service.

const (
	// FileRegistration uses a configuration file for registration.
	FileRegistration RegistrationMethod = "file"
	// GRPCRegistration uses the RegistrationService via gRPC.
	GRPCRegistration RegistrationMethod = "grpc"
	// JSONRPCRegistration uses the RegistrationService via JSON-RPC.
	JSONRPCRegistration RegistrationMethod = "jsonrpc"
)

Jump to

Keyboard shortcuts

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