flagstest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0, MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package flagstest helps test code that uses flags: an in-memory manager with forced values, and a contract suite for Store implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunStoreContract

func RunStoreContract(t *testing.T, factory func(testing.TB) flags.Store)

RunStoreContract runs the behavior every flags.Store must have. factory returns an empty Store and is called once per subtest.

Types

type Tester

type Tester struct {
	*flags.Manager
	// contains filtered or unexported fields
}

Tester is a flags.Manager on a MemStore for tests. Flags that are neither defined nor forced are off.

func New

func New(tb testing.TB) *Tester

New returns a Tester.

func (*Tester) Force

func (x *Tester) Force(name string, val any)

Force makes the flag return val for every scope. The flag is defined if it was not, with the type of val; forcing a defined flag with a value of another type fails the test.

func (*Tester) ForceFor

func (x *Tester) ForceFor(name string, scope flags.Scope, val any)

ForceFor makes the flag return val for scope only.

func (*Tester) Reset

func (x *Tester) Reset()

Reset removes every forced and stored value. Definitions stay.

Jump to

Keyboard shortcuts

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