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 ¶
type Config ¶
Config is a policyclient.Client implementation with a static mapping of values.
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 different expected type and/or value. Some accessors such as GetPreferenceOption and GetVisibility support either a ptype.PreferenceOption/ptype.Visibility in the map, or the string representation as supported by their UnmarshalText methods.
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 RegisterChangeCallback for testing. Without calling this, the RegisterChangeCallback does nothing. For watchers to be notified, use the Config.Set method. Changing the map directly obviously wouldn't work.
func (Config) GetDuration ¶
func (Config) GetPreferenceOption ¶
func (c Config) GetPreferenceOption(key pkey.Key, defaultVal ptype.PreferenceOption) (ptype.PreferenceOption, error)
func (Config) GetStringArray ¶
func (Config) GetVisibility ¶
func (Config) RegisterChangeCallback ¶
func (c Config) 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 will be read as later. For PreferenceOption and Visibility, you may also set them to 'string' values and they'll be UnmarshalText'ed into their correct value at Get time.
As a special case, the value can also be of type error to make the accessors return that error value.
func (Config) SetDebugLoggingEnabled ¶
func (*Config) SetMultiple ¶
SetMultiple is a batch version of Config.Set. It copies the contents of o into c and does at most one notification wake-up for the whole batch.