openapitest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 13 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) agentkit.ToolProvider

NewProvider builds tool/openapi against a materialized workspace.

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