Documentation
¶
Overview ¶
Package testutils provides utils for testing should not be imported by any other app packages
Index ¶
- func AssertContentsSameAsFixture(t *testing.T, targetFile, fixtureFile string)
- func AssertFileDoesNotExist(t *testing.T, path string)
- func AssertFileExists(t *testing.T, path string)
- func AssertFixture(t *testing.T, target, fixture string, regenerate bool)
- func AssertIsSymlink(t *testing.T, path string)
- func AssertLogsPresent(t *testing.T, logs []byte, expectedIDs []utils.LogID)
- func ContentSameAsFixture(t *testing.T, targetFile, fixtureFile string) error
- func CreateLidConfig(busName, objectPath string) *config.LidSection
- func CreatePowerConfig(busName, objectPath string) *config.PowerSection
- func CreateTestLidConfig(t *testing.T, busName, objectPath string) *config.Config
- func CreateTestPowerConfig(t *testing.T, busName, objectPath string) *config.Config
- func GenerateTestBusName() string
- func GenerateTestObjectPath() string
- func Logf(t *testing.T, format string, args ...any)
- func RequireEqualOutput(tb testing.TB, out []byte)
- func SetupFakeConfigUpdater(t *testing.T, updates []*TestConfig, ...) chan struct{}
- func SetupFakeDbusEventsServer(t *testing.T, service *TestDbusService, events []power.PowerState, ...) chan struct{}
- func SetupFakeDbusLidEventsServer(t *testing.T, service *TestDbusService, events []power.LidState, ...) chan struct{}
- func SetupFakeHyprEventsServer(ctx context.Context, t *testing.T, listener net.Listener, events []string) chan struct{}
- func SetupFakeHyprEventsServerWithSleep(ctx context.Context, t *testing.T, listener net.Listener, events []string, ...) chan struct{}
- func SetupFakeHyprIPCWriter(t *testing.T, listener net.Listener, responseData [][]byte, ...) chan struct{}
- func SetupHyprEnvVars(t *testing.T) (string, string)
- func SetupHyprSocket(ctx context.Context, t *testing.T, xdgRuntimeDir, signature string, ...) (net.Listener, func())
- func UpdateFixture(t *testing.T, targetFile, fixtureFile string)
- type FinalOpt
- type FinalOpts
- type TestConfig
- func (t *TestConfig) FillDefaults() *TestConfig
- func (t *TestConfig) FillFallbackProfileConfigFile(path string) *TestConfig
- func (t *TestConfig) FillProfileConfigFile(name, path string) *TestConfig
- func (t *TestConfig) Get() *config.Config
- func (t *TestConfig) RequireLid(power config.LidStateType) *TestConfig
- func (t *TestConfig) RequirePower(power config.PowerStateType) *TestConfig
- func (t *TestConfig) SaveToFile() *TestConfig
- func (t *TestConfig) WithConfigDir(dir string) *TestConfig
- func (t *TestConfig) WithConfigPath(path string) *TestConfig
- func (t *TestConfig) WithDestination(dest string) *TestConfig
- func (t *TestConfig) WithDestinationContents(filepath string) *TestConfig
- func (t *TestConfig) WithFallbackProfile(fallback *config.Profile) *TestConfig
- func (t *TestConfig) WithFilewatcherDebounceTime(ms int) *TestConfig
- func (t *TestConfig) WithHotReload(h *config.HotReloadSection) *TestConfig
- func (t *TestConfig) WithLidSection(ps *config.LidSection) *TestConfig
- func (t *TestConfig) WithNotifications(n *config.Notifications) *TestConfig
- func (t *TestConfig) WithPostExec(fun string) *TestConfig
- func (t *TestConfig) WithPowerSection(ps *config.PowerSection) *TestConfig
- func (t *TestConfig) WithPreExec(fun string) *TestConfig
- func (t *TestConfig) WithProfiles(profiles map[string]*config.Profile) *TestConfig
- func (t *TestConfig) WithScoring(scoring *config.ScoringSection) *TestConfig
- func (t *TestConfig) WithServiceDebounceTime(ms int) *TestConfig
- func (t *TestConfig) WithStaticTemplateValues(s map[string]string) *TestConfig
- func (t *TestConfig) WithThemeFile(file string) *TestConfig
- type TestDbusService
- type TestModel
- func (t *TestModel) FinalOutput(opts ...FinalOpt) (string, error)
- func (t *TestModel) FinalScreen(opts ...FinalOpt) (string, error)
- func (t *TestModel) Read(p []byte) (n int, err error)
- func (t *TestModel) Send(sequence []byte) error
- func (t *TestModel) Type(s string) error
- func (t *TestModel) WaitFinished(opts ...FinalOpt) error
- func (t *TestModel) WaitFor(condition func(bts []byte) bool, options ...WaitForOption) error
- type TestModelOptions
- type TestOption
- type WaitForOption
- type WaitingForContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFileDoesNotExist ¶
func AssertFileExists ¶
func AssertFixture ¶ added in v1.2.0
func AssertIsSymlink ¶
func AssertLogsPresent ¶
func ContentSameAsFixture ¶
func CreateLidConfig ¶ added in v1.3.0
func CreateLidConfig(busName, objectPath string) *config.LidSection
func CreatePowerConfig ¶
func CreatePowerConfig(busName, objectPath string) *config.PowerSection
func CreateTestLidConfig ¶ added in v1.3.0
func CreateTestPowerConfig ¶
func GenerateTestBusName ¶
func GenerateTestBusName() string
func GenerateTestObjectPath ¶
func GenerateTestObjectPath() string
func RequireEqualOutput ¶ added in v1.3.2
func SetupFakeConfigUpdater ¶
func SetupFakeDbusEventsServer ¶
func SetupFakeDbusEventsServer(t *testing.T, service *TestDbusService, events []power.PowerState, initialSleep, sleepBetweenEvents time.Duration, binaryStarting <-chan struct{}, ) chan struct{}
func SetupFakeDbusLidEventsServer ¶ added in v1.3.0
func SetupFakeHyprEventsServerWithSleep ¶ added in v1.3.2
func SetupFakeHyprIPCWriter ¶
func SetupHyprSocket ¶
func UpdateFixture ¶
Types ¶
type FinalOpt ¶ added in v1.3.2
type FinalOpt func(opts *FinalOpts)
func WithFinalTimeout ¶ added in v1.3.2
type FinalOpts ¶ added in v1.3.2
type FinalOpts struct {
// contains filtered or unexported fields
}
type TestConfig ¶
type TestConfig struct {
// contains filtered or unexported fields
}
func NewTestConfig ¶
func NewTestConfig(t *testing.T) *TestConfig
func (*TestConfig) FillDefaults ¶
func (t *TestConfig) FillDefaults() *TestConfig
func (*TestConfig) FillFallbackProfileConfigFile ¶
func (t *TestConfig) FillFallbackProfileConfigFile(path string) *TestConfig
func (*TestConfig) FillProfileConfigFile ¶
func (t *TestConfig) FillProfileConfigFile(name, path string) *TestConfig
func (*TestConfig) Get ¶
func (t *TestConfig) Get() *config.Config
func (*TestConfig) RequireLid ¶ added in v1.3.0
func (t *TestConfig) RequireLid(power config.LidStateType) *TestConfig
func (*TestConfig) RequirePower ¶
func (t *TestConfig) RequirePower(power config.PowerStateType) *TestConfig
func (*TestConfig) SaveToFile ¶
func (t *TestConfig) SaveToFile() *TestConfig
func (*TestConfig) WithConfigDir ¶
func (t *TestConfig) WithConfigDir(dir string) *TestConfig
func (*TestConfig) WithConfigPath ¶
func (t *TestConfig) WithConfigPath(path string) *TestConfig
func (*TestConfig) WithDestination ¶
func (t *TestConfig) WithDestination(dest string) *TestConfig
func (*TestConfig) WithDestinationContents ¶ added in v1.3.10
func (t *TestConfig) WithDestinationContents(filepath string) *TestConfig
func (*TestConfig) WithFallbackProfile ¶
func (t *TestConfig) WithFallbackProfile(fallback *config.Profile) *TestConfig
func (*TestConfig) WithFilewatcherDebounceTime ¶
func (t *TestConfig) WithFilewatcherDebounceTime(ms int) *TestConfig
func (*TestConfig) WithHotReload ¶
func (t *TestConfig) WithHotReload(h *config.HotReloadSection) *TestConfig
func (*TestConfig) WithLidSection ¶ added in v1.3.0
func (t *TestConfig) WithLidSection(ps *config.LidSection) *TestConfig
func (*TestConfig) WithNotifications ¶
func (t *TestConfig) WithNotifications(n *config.Notifications) *TestConfig
func (*TestConfig) WithPostExec ¶
func (t *TestConfig) WithPostExec(fun string) *TestConfig
func (*TestConfig) WithPowerSection ¶
func (t *TestConfig) WithPowerSection(ps *config.PowerSection) *TestConfig
func (*TestConfig) WithPreExec ¶
func (t *TestConfig) WithPreExec(fun string) *TestConfig
func (*TestConfig) WithProfiles ¶
func (t *TestConfig) WithProfiles(profiles map[string]*config.Profile) *TestConfig
func (*TestConfig) WithScoring ¶
func (t *TestConfig) WithScoring(scoring *config.ScoringSection) *TestConfig
func (*TestConfig) WithServiceDebounceTime ¶
func (t *TestConfig) WithServiceDebounceTime(ms int) *TestConfig
func (*TestConfig) WithStaticTemplateValues ¶
func (t *TestConfig) WithStaticTemplateValues(s map[string]string) *TestConfig
func (*TestConfig) WithThemeFile ¶ added in v1.4.0
func (t *TestConfig) WithThemeFile(file string) *TestConfig
type TestDbusService ¶
type TestDbusService struct {
// contains filtered or unexported fields
}
TestDbusService provides a mock D-Bus service for testing
func NewTestDbusService ¶
func NewTestDbusService(t *testing.T, conn *dbus.Conn, initial power.PowerState, objectPath string) *TestDbusService
func SetupTestDbusService ¶
func SetupTestDbusService(t *testing.T) (*TestDbusService, string, string, func())
func (*TestDbusService) EmitSignal ¶
func (s *TestDbusService) EmitSignal() error
func (*TestDbusService) SetLidProperty ¶ added in v1.3.0
func (s *TestDbusService) SetLidProperty(value power.LidState)
func (*TestDbusService) SetProperty ¶
func (s *TestDbusService) SetProperty(value power.PowerState)
type TestModel ¶ added in v1.3.2
type TestModel struct {
// contains filtered or unexported fields
}
func NewTestModel ¶ added in v1.3.2
func NewTestModel(options ...TestOption) (*TestModel, error)
func (*TestModel) FinalOutput ¶ added in v1.3.2
func (*TestModel) FinalScreen ¶ added in v1.3.2
func (*TestModel) WaitFinished ¶ added in v1.3.2
type TestModelOptions ¶ added in v1.3.2
type TestModelOptions struct {
// contains filtered or unexported fields
}
type TestOption ¶ added in v1.3.2
type TestOption func(opts *TestModelOptions)
func WithCommand ¶ added in v1.3.2
func WithCommand(cmd *exec.Cmd) TestOption
func WithExitSequences ¶ added in v1.3.2
func WithExitSequences(seq []string) TestOption
func WithInitialTermSize ¶ added in v1.3.2
func WithInitialTermSize(width, height int) TestOption
type WaitForOption ¶ added in v1.3.2
type WaitForOption func(*WaitingForContext)
func WithCheckInterval ¶ added in v1.3.2
func WithCheckInterval(d time.Duration) WaitForOption
func WithDuration ¶ added in v1.3.2
func WithDuration(d time.Duration) WaitForOption
Click to show internal directories.
Click to hide internal directories.