policytest
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package policytest contains test helpers for the syspolicy packages.
Index¶
- type Config
- func (c *Config) EnableRegisterChangeCallback()
- func (c Config) GetBoolean(key pkey.Key, defaultVal bool) (bool, error)
- func (c Config) GetDuration(key pkey.Key, defaultVal time.Duration) (time.Duration, error)
- func (c Config) GetPreferenceOption(key pkey.Key, defaultVal ptype.PreferenceOption) (ptype.PreferenceOption, error)
- func (c Config) GetString(key pkey.Key, defaultVal string) (string, error)
- func (c Config) GetStringArray(key pkey.Key, defaultVal []string) ([]string, error)
- func (c Config) GetUint64(key pkey.Key, defaultVal uint64) (uint64, error)
- func (c Config) GetVisibility(key pkey.Key) (ptype.Visibility, error)
- func (c Config) HasAnyOf(keys ...pkey.Key) (bool, error)
- func (c Config) RegisterChangeCallback(callback func(policyclient.PolicyChange)) (func(), error)
- func (c *Config) Set(key pkey.Key, value any)
- func (sp Config) SetDebugLoggingEnabled(enabled bool)
- func (c *Config) SetMultiple(o Config)
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeConfig¶
Config is apolicyclient.Client implementation with a static mapping ofvalues.
It is used for testing purposes to simulate policy client behavior.
It panics if a value is Set with one type and then accessed with a differentexpected type and/or value. Some accessors such as GetPreferenceOption andGetVisibility support either a ptype.PreferenceOption/ptype.Visibility in themap, or the string representation as supported by their UnmarshalTextmethods.
The map value may be an error to return that error value from the accessor.
func (*Config)EnableRegisterChangeCallback¶
func (c *Config) EnableRegisterChangeCallback()
EnableRegisterChangeCallback makes c support the RegisterChangeCallbackfor testing. Without calling this, the RegisterChangeCallback does nothing.For watchers to be notified, use theConfig.Set method. Changing the mapdirectly obviously wouldn't work.
func (Config)GetDuration¶
func (Config)GetPreferenceOption¶
func (cConfig) GetPreferenceOption(keypkey.Key, defaultValptype.PreferenceOption) (ptype.PreferenceOption,error)
func (Config)GetStringArray¶
func (Config)GetVisibility¶
func (Config)RegisterChangeCallback¶
func (cConfig) RegisterChangeCallback(callback func(policyclient.PolicyChange)) (func(),error)
func (*Config)Set¶
Set sets key to value. The value should be of the correct type that it willbe read as later. For PreferenceOption and Visibility, you may also set themto 'string' values and they'll be UnmarshalText'ed into their correct valueat Get time.
As a special case, the value can also be of type error to make the accessorsreturn that error value.
func (Config)SetDebugLoggingEnabled¶
func (*Config)SetMultiple¶
SetMultiple is a batch version ofConfig.Set. It copies the contents of ointo c and does at most one notification wake-up for the whole batch.