testharness

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package testharness provides test-only request, SQLite, and generated-module fixtures. Production packages must not import it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertJSONEqual

func AssertJSONEqual(t *testing.T, expectedJSON string, actual any)

func DecodeJSON

func DecodeJSON[T any](raw string) (*T, error)

func GeneratedGoMod

func GeneratedGoMod() string

GeneratedGoMod retains the existing test entrypoint over the shared owner.

func GeneratedGoModWithoutModule

func GeneratedGoModWithoutModule() string

GeneratedGoModWithoutModule is for tests that deliberately verify missing module identity; all local dependencies still come from the actual checkout.

func StructuredObject

func StructuredObject(t testing.TB, value any) map[string]any

StructuredObject asserts an object-shaped structured protocol payload. MCP's schema permits any JSON value; tests of object contracts must prove the shape before indexing it.

func WriteGeneratedGoMod

func WriteGeneratedGoMod(t *testing.T, root string)

Types

type Fixture

type Fixture struct {
	SchemaSQL string
	SeedSQL   string
	Request   string
	Expected  string
}

func LoadFixture

func LoadFixture(dir string) (*Fixture, error)

type GeneratedModule

type GeneratedModule struct {
	Path       string
	SourceRoot string
}

GeneratedModule derives fixture replacements from the actual source checkout, so generated tests do not assume a GOPATH layout or a second Datly checkout.

func (GeneratedModule) Content

func (m GeneratedModule) Content() (string, error)

func (GeneratedModule) DependencyDir

func (m GeneratedModule) DependencyDir(name string) (string, error)

func (GeneratedModule) Write

func (m GeneratedModule) Write(t testing.TB, root string)

func (GeneratedModule) WriteSums

func (m GeneratedModule) WriteSums(t testing.TB, root string)

WriteSums copies the source checkout's verified dependency sums into a fixture. This avoids module verification downloads for unchanged dependency selections.

type Harness

type Harness struct{ *sqlite.Harness }

Harness adds component fixtures to the shared, dependency-light SQLite owner.

func NewSQLiteHarness

func NewSQLiteHarness(t *testing.T, opts ...HarnessOption) *Harness

func (*Harness) ApplyFixture

func (h *Harness) ApplyFixture(ctx context.Context, fixture *Fixture) error

type HarnessOption

type HarnessOption = sqlite.Option

func WithDSN

func WithDSN(dsn string) HarnessOption

type JWT

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

JWT supplies local signed credentials and verifier resources without a TCP server.

func NewJWT

func NewJWT(t testing.TB) *JWT

func (*JWT) Config

func (j *JWT) Config() *verifier.Config

func (*JWT) Sign

func (j *JWT) Sign(t testing.TB, subject string, expires time.Time) string

type Output

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

Output captures concurrent command output and waits for complete readiness lines.

func (*Output) String

func (o *Output) String() string

func (*Output) WaitLine

func (o *Output) WaitLine(ctx context.Context, prefix string) (string, error)

func (*Output) Write

func (o *Output) Write(p []byte) (int, error)

type Request

type Request struct {
	HTTP       *http.Request
	PathParams map[string]string
}

Request is a synthetic HTTP provider scope for tests.

func NewRequest

func NewRequest(method, path string) Request

func (Request) Providers

func (r Request) Providers() []locator.Provider

func (Request) Scope

func (r Request) Scope() (*requestprovider.Scope, error)

func (Request) WithBody

func (r Request) WithBody(body []byte, contentType string) Request

func (Request) WithHeaders

func (r Request) WithHeaders(headers http.Header) Request

func (Request) WithPathParams

func (r Request) WithPathParams(pathParams map[string]string) Request

func (Request) WithQuery

func (r Request) WithQuery(query url.Values) Request

func (Request) WithRequest

func (r Request) WithRequest(request *http.Request) Request

Directories

Path Synopsis
Package auth supplies local RSA/JWT fixtures using the actual Datly verifier.
Package auth supplies local RSA/JWT fixtures using the actual Datly verifier.
Package devapp provides linked SQLite application fixtures for developer MCP tests.
Package devapp provides linked SQLite application fixtures for developer MCP tests.
Package genpatch owns the shared high-level generation acceptance fixture.
Package genpatch owns the shared high-level generation acceptance fixture.
Package mcpclient runs real viant/mcp client/server transport tests.
Package mcpclient runs real viant/mcp client/server transport tests.
Package otlp provides a real protobuf HTTP collector for integration tests.
Package otlp provides a real protobuf HTTP collector for integration tests.
Package sqlite provides shared SQLite fixtures and typed SQLX result verification for dependency-light data-driven tests.
Package sqlite provides shared SQLite fixtures and typed SQLX result verification for dependency-light data-driven tests.

Jump to

Keyboard shortcuts

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