sdktest

package
v0.4.22 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sdktest contains test-only helpers for module contract tests.

Index

Constants

This section is empty.

Variables

View Source
var ErrContributionSlotNotProvided = errors.New("sdktest: contribution slot is not provided")

ErrContributionSlotNotProvided means the host manifest does not declare the slot targeted by an outbound contribution.

View Source
var ErrNoContributionsToHost = errors.New("sdktest: contributor does not target host")

ErrNoContributionsToHost means the contributor manifest does not target the supplied host by its manifest ID, slug, or an explicitly supplied reference.

Functions

func Manifest

func Manifest(t TB, handler http.Handler, internalSecret string) system.ManifestPayload

Manifest requests and decodes the SDK manifest exposed by handler. internalSecret must match the module's configured internal credential.

func TablesMissingPrefix added in v0.4.21

func TablesMissingPrefix(ctx context.Context, q db.Querier, moduleID, schema string) ([]string, error)

TablesMissingPrefix returns the base tables in schema whose name does not start with "<moduleID>_", sorted by name. SDK-owned tables (schema_migrations) are excluded. Run it after the module's migrations have been applied.

func ValidateContributionPayload

func ValidateContributionPayload(host system.ManifestPayload, outbound OutboundContribution) error

ValidateContributionPayload checks one contributor manifest entry against the exact JSON Schema advertised by its host manifest.

func ValidateContributionsToHost

func ValidateContributionsToHost(host, contributor system.ManifestPayload, hostReferences ...string) error

ValidateContributionsToHost checks every entry in contributor that targets host. Exact catalog references such as "@owner/user-core" belong in hostReferences because a manifest's slug cannot authenticate or reconstruct its catalog owner. It is the compatibility gate for unchanged module canaries.

func ValidateTablePrefix added in v0.4.21

func ValidateTablePrefix(t testing.TB, ctx context.Context, q db.Querier, moduleID, schema string)

ValidateTablePrefix fails t when any table in schema does not start with "<moduleID>_". Every table a module creates in its shared app_<id> schema must carry that prefix so two modules cannot collide on a name like "items".

It is an integration-test helper: q must be a live connection (a *pgxpool.Pool works) pointing at a database where the module's migrations have already been applied into schema. Callers skip the test themselves when no database is configured:

func TestTablePrefix(t *testing.T) {
    pool := connectOrSkip(t)
    sdktest.ValidateTablePrefix(t, context.Background(), pool, "mymod", "app_xxx")
}

Types

type OutboundContribution

type OutboundContribution = registry.OutboundContribution

OutboundContribution is one contributor-side manifest declaration.

type TB

type TB interface {
	Helper()
	Fatalf(format string, args ...any)
}

TB is the subset of testing.TB used by this package.

Jump to

Keyboard shortcuts

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