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

openapitest

package
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package openapitest provides a reusable mock HTTP API, fixture workspace materialization, and helpers for OpenAPI dynamic tool smoke tests.

Index

Constants

View Source
const (
	// DefaultToken is the bearer token expected by the mock API and fixture auth.
	DefaultToken = "openapitest-token"
	// BaseURLPlaceholder is substituted when materializing api.json from fixtures.
	BaseURLPlaceholder = "{{BASE_URL}}"
)

Variables

This section is empty.

Functions

func FixturesDir

func FixturesDir(t *testing.T) string

FixturesDir returns the repo-relative fixtures/openapi directory.

func Materialize

func Materialize(t *testing.T, baseURL string, apiFile ...string) string

Materialize copies fixture files into a temp workspace and substitutes baseURL into the chosen api.json variant (default api.json).

func NewProvider

func NewProvider(t *testing.T, root string, newProvider func(ws workspace.Service, creds credentials.Store) (agentkit.ToolProvider, error)) agentkit.ToolProvider

NewProvider builds an OpenAPI tool provider against a materialized workspace. newProvider builds the plugin provider from the workspace and credential store; openapitest stays plugin-agnostic, callers inject the tool/openapi constructor.

func ToolByName

func ToolByName(t *testing.T, ctx context.Context, provider agentkit.ToolProvider, name string) agentkit.Tool

ToolByName lists tools from the provider and returns the named tool.

func TurnContext

func TurnContext(sessionID agentkit.SessionID, agentID agentkit.AgentID, userID string, metadata map[string]any) context.Context

TurnContext returns a turn context seeded for bind tests.

func Workspace

func Workspace(root string) workspace.Service

Workspace returns a workspace.Service rooted at the materialized fixture dir.

Types

type Mock

type Mock struct {
	Server *httptest.Server
	URL    string
}

Mock serves the petstore-like HTTP API used in OpenAPI smoke tests.

func StartMock

func StartMock(t *testing.T) *Mock

StartMock starts an httptest server for the OpenAPI fixture API.

Jump to

Keyboard shortcuts

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