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
- type Reference
- func (r *Reference) Check(key string, raw map[string]any, out any)
- func (r *Reference) Decode(key string, out any, except ...string)
- func (r *Reference) DecodeEach(key string, newOut func() any)
- func (r *Reference) DecodeEndpoints(key string)
- func (r *Reference) Delegate(keys ...string)
- func (r *Reference) Read(keys ...string)
- func (r *Reference) RequireComplete(roots ...string)
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Delegate covers the subtrees at keys, which the reference test of the component that reads them checks, calling RequireComplete on them.
func (*Reference) Read ¶
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 ¶
RequireComplete fails the test for every documented key under roots that is neither decoded, read, nor delegated.