Documentation
¶
Overview ¶
Package testseam turns the package-var injection-seam swap into a mechanism instead of a convention. Tests that stub a package-level function var (e.g. pipelineBuildEffectiveRegistry) must use Swap so the previous value is structurally restored via t.Cleanup; a forgotten restore then cannot leak state into sibling tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Protect ¶
Protect snapshots *ptr and restores it at test end without replacing it. Use it when the code under test mutates the seam itself (e.g. os.Args) and no stub value is available up front. Same sequential-only caveat as Swap.
func Swap ¶
Swap replaces *ptr with next for the duration of the test and restores the previous value when the test ends. It is the required form for package-var seam swaps:
testseam.Swap(t, &somePackageFn, func(args) (ret, error) { ... })
Prefer it over the manual `prev := fn; t.Cleanup(...); fn = stub` trio: Swap cannot forget the restore. Like the manual pattern it replaces, Swap mutates process-global state and is therefore NOT safe for t.Parallel tests — sequential tests only.
Types ¶
This section is empty.