schematest

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package schematest is a test-only helper for constructing schema.Cache instances against the workspace-local CUE module cache.

Tests across opm/schema/, opm/helper/synth/, and opm/kernel/ exercise the real OCILoader code path; no test-only Loader exists in the library. The workspace cache directory (library/.cue-cache/) is gitignored. First test run on a fresh checkout fetches opmodel.dev/core@v0 from CUE_REGISTRY (default schema.PublicRegistry → GHCR); subsequent runs hit the workspace cache.

This package is under opm/internal/ — only opm/* packages may import it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LibraryRoot

func LibraryRoot(t testing.TB) string

LibraryRoot returns the absolute path to the library/ directory (the one containing go.mod, opm/, testdata/, …) resolved via runtime.Caller relative to this file.

func NewCache

func NewCache(t testing.TB) *schema.Cache

NewCache returns a fresh *schema.Cache backed by a zero-value schema.OCILoader. It also configures CUE_REGISTRY and CUE_CACHE_DIR via SetEnv so the loader resolves opmodel.dev/core@v0 against the public registry into the workspace-local cache.

Memoization is per-call: distinct tests get distinct caches to keep per-test state explicit. Tests that need to share a Cache across multiple synth calls within one test should hold the returned pointer for the duration of the test.

func SetEnv

func SetEnv(t testing.TB)

SetEnv configures CUE_REGISTRY and CUE_CACHE_DIR for the test scope via t.Setenv. Registry defaults to schema.PublicRegistry; the cache directory is WorkspaceCacheDir. The settings revert at test scope (t.Cleanup semantics).

func WorkspaceCacheDir

func WorkspaceCacheDir(t testing.TB) string

WorkspaceCacheDir returns the absolute path to library/.cue-cache/ — the per-workspace CUE module cache used by tests. The directory is created lazily by cue/load.Instances on first use; tests do not need to mkdir it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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