configtest

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package configtest checks the reference configuration in docs/configuration.md against the code that reads it. It is imported only by tests.

UnmarshalKey ignores keys that no struct field matches, so a misspelled, misplaced or no longer read key in a node's configuration falls back to its default without an error. Each platform keeps the reference honest with a test that claims its sections of the document: Reference.Decode, Reference.DecodeEach and Reference.DecodeEndpoints strictly decode the sections the code decodes into a struct, Reference.Read lists the keys the code reads one at a time, Reference.Delegate hands a section to the test of the component that reads it, and Reference.RequireComplete fails on any documented key under the claimed roots that none of these covered.

Index

Constants

View Source
const Network = "fabric.mynetwork"

Network is the name of the Fabric network documented in the reference.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reference

type Reference struct {
	*config.Provider
	// contains filtered or unexported fields
}

Reference is the first yaml block of docs/configuration.md together with the keys a test has covered so far. A Reference is not safe for concurrent use.

func Load

func Load(t *testing.T) *Reference

Load returns the reference configuration. It is loaded without config.NewProvider, which merges CORE_* environment variables on top of the file and would make the result depend on the environment the test runs in.

func (*Reference) Check

func (r *Reference) Check(key string, raw map[string]any, out any)

Check strictly decodes raw into out, failing the test with key in the message if raw holds a key that out has no field for. It records no coverage; use it for maps nested in a section that is covered otherwise, such as the free-form options of an array element.

func (*Reference) Decode

func (r *Reference) Decode(key string, out any, except ...string)

Decode strictly decodes the subtree at key into out and covers every leaf it decoded. The keys in except, relative to key and possibly dotted, are left out of the decode and stay uncovered: the test covers them separately, typically because the code resolves them on their own, as it does tls: blocks.

func (*Reference) DecodeEach

func (r *Reference) DecodeEach(key string, newOut func() any)

DecodeEach strictly decodes each element of the array at key into a value from newOut and covers the array. An array is a single key in the configuration, so its elements need no further coverage.

func (*Reference) DecodeEndpoints

func (r *Reference) DecodeEndpoints(key string)

DecodeEndpoints is Reference.DecodeEach for an array of grpc.ConnectionConfig. An element's tls block is decoded as client TLS, the way tlsconfig.ResolveEndpointClients resolves it, and is left out of the element's decode.

func (*Reference) Delegate

func (r *Reference) Delegate(keys ...string)

Delegate covers the subtrees at keys, which the reference test of the component that reads them checks, calling RequireComplete on them.

func (*Reference) Read

func (r *Reference) Read(keys ...string)

Read covers keys that the code reads one at a time (GetString, GetInt, IsSet, ...), so no strict decode can check them. Each key must be a documented leaf.

func (*Reference) RequireComplete

func (r *Reference) RequireComplete(roots ...string)

RequireComplete fails the test for every documented key under roots that is neither decoded, read, nor delegated.

Jump to

Keyboard shortcuts

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