Documentation
¶
Overview ¶
Package registrytest provides an in-memory OCI registry harness for tests that need to materialize catalogs without a live registry.
It stands up a modregistrytest registry serving inline `c.#Catalog` fixtures under the CatalogPrefix module path, while opmodel.dev/core@v0 still resolves from the warm workspace cache (via schematest.SetEnv). The CUE_REGISTRY mapping routes the test prefix to the in-process host and leaves every other path on the public registry.
It lives under opm/internal/ so it stays out of the library's public SemVer surface (kernel neutrality) while remaining importable from any opm/* test package. The materialize tests and the kernel integration harness share it so registry semantics never drift between them.
Index ¶
- Constants
- func BuildCatalog(path, version string, txs ...TxFixture) string
- func BuildPlatform(t *testing.T, octx *cue.Context, registryBody string) *platform.Platform
- func NewCatalogRegistry(t *testing.T, fixtures ...CatalogFixture) string
- func UniquePath(t *testing.T, leaf string) string
- type CatalogFixture
- type CtxOwner
- type TxFixture
Constants ¶
const CatalogPrefix = "test.example"
CatalogPrefix is the module-path prefix every in-memory catalog fixture lives under. The CUE_REGISTRY mapping routes this prefix to the in-process registry while opmodel.dev (core@v0) still resolves from the public registry / warm workspace cache.
Variables ¶
This section is empty.
Functions ¶
func BuildCatalog ¶
BuildCatalog renders a complete catalog package body (the text after the bare `c.#Catalog` line) for the given module path/version and transformer fixtures. The #Catalog pattern stamps each transformer's metadata.modulePath ("<path>/transformers") and version; this only authors name, description, the required-primitive maps, and the transform output (from TxFixture.Output, defaulting to an empty struct).
func BuildPlatform ¶
BuildPlatform builds a concrete *platform.Platform whose #registry contains the given map body (e.g. `{ "test.example/.../cat": {enable: true} }`), validated against core's #Platform. The platform value is built with octx so Materialize can fill catalog values (built with the same context) onto it. CUE_REGISTRY / CUE_CACHE_DIR must already be configured (e.g. by NewCatalogRegistry) so #Platform resolves from the warm workspace cache.
func NewCatalogRegistry ¶
func NewCatalogRegistry(t *testing.T, fixtures ...CatalogFixture) string
NewCatalogRegistry stands up an in-memory OCI registry serving the given catalog fixtures and configures CUE_REGISTRY / CUE_CACHE_DIR for the test scope: the test prefix routes to the in-process host (+insecure), while opmodel.dev/core resolves from the public registry via the warm workspace cache. Returns the CUE_REGISTRY mapping string. The registry is torn down at test end.
Fixture layout follows modregistrytest.New: one directory per (module, version) named "<path with / → _>_v<X.Y.Z>", each holding cue.mod/module.cue (module + language version + the opmodel.dev/core@v0 dep) and catalog.cue (package body importing core and unifying c.#Catalog).
func UniquePath ¶
UniquePath returns a globally-unique catalog module path for the current test. Uniqueness matters because all tests share the warm workspace CUE module cache (download cache keyed by module path + version): distinct paths prevent one test's fixture content from shadowing another's.
Types ¶
type CatalogFixture ¶
type CatalogFixture struct {
Path string // module path without the @major suffix, e.g. "test.example/x/cat"
Version string // bare SemVer, e.g. "0.1.0"
Body string // catalog package body (metadata + #transformers)
}
CatalogFixture is one (path, version) catalog module published into the in-memory registry. Body is the catalog package body that follows the bare `c.#Catalog` line (see BuildCatalog).
type CtxOwner ¶
type CtxOwner struct {
// contains filtered or unexported fields
}
CtxOwner is a minimal materialize.CueContextOwner wrapping a *cue.Context, so tests can drive Materialize without constructing a full *kernel.Kernel (which would create an import cycle through materialize).
func NewCtxOwner ¶
NewCtxOwner wraps ctx as a CueContextOwner.
func (CtxOwner) CueContext ¶
CueContext returns the wrapped context.
type TxFixture ¶
type TxFixture struct {
Name string
Resources []string
Traits []string
Output string // optional inline #transform.output literal; "" → "{}"
}
TxFixture describes one transformer to author into a test catalog: its kebab name plus the short names of the resources/traits it requires (used to populate the #matchers reverse index). Output is an optional inline `#transform.output` literal (a CUE struct or list expression); when empty it defaults to an empty struct.