Test against a registry of your own¶
The default registry is process-wide and never reset. A test that needs a feature, a contribution or a set of its own builds a registry:
r := features.NewRegistry()
require.NoError(t, r.Declare(fakeFeature{id: "beta", dynamic: true}))
r.Contribute("beta", slotCheck, fakeCheck)
set, err := features.Resolve(r.Snapshot(), []features.State{{ID: "beta", Enabled: true}})
Every such test runs under t.Parallel(): nothing it does is visible outside it, and
nothing another test does is visible to it.
For the dynamic half, hand Dynamic a scripted Backend: a Ready() that returns
false makes every dynamic evaluation a fallback with ErrBackendNotReady; a Resolve
that returns an error does the same with your error; SetBackend(set) proves the
happy path with no vendor.
Every role is an interface (Registry, Snapshot, Resolver, Set, Evaluator,
Backend), so a mock of any of them is a valid substitute where a real one would be
heavier than the assertion warrants.