testutils

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package testutils provides utils for testing should not be imported by any other app packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertContentsSameAsFixture

func AssertContentsSameAsFixture(t *testing.T, targetFile, fixtureFile string)

func AssertFileDoesNotExist

func AssertFileDoesNotExist(t *testing.T, path string)

func AssertFileExists

func AssertFileExists(t *testing.T, path string)

func AssertFixture added in v1.2.0

func AssertFixture(t *testing.T, target, fixture string, regenerate bool)
func AssertIsSymlink(t *testing.T, path string)

func AssertLogsPresent

func AssertLogsPresent(t *testing.T, logs []byte, expectedIDs []utils.LogID)

func ContentSameAsFixture

func ContentSameAsFixture(t *testing.T, targetFile, fixtureFile string) error

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 CreateTestLidConfig(t *testing.T, busName, objectPath string) *config.Config

func CreateTestPowerConfig

func CreateTestPowerConfig(t *testing.T, busName, objectPath string) *config.Config

func GenerateTestBusName

func GenerateTestBusName() string

func GenerateTestObjectPath

func GenerateTestObjectPath() string

func Logf added in v0.1.4

func Logf(t *testing.T, format string, args ...any)

func RequireEqualOutput added in v1.3.2

func RequireEqualOutput(tb testing.TB, out []byte)

func SetupFakeConfigUpdater

func SetupFakeConfigUpdater(t *testing.T, updates []*TestConfig,
	initialSleep, sleepBetweenEvents time.Duration, binaryStarting <-chan struct{}, configPath string,
) chan struct{}

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 SetupFakeDbusLidEventsServer(t *testing.T, service *TestDbusService, events []power.LidState,
	initialSleep, sleepBetweenEvents time.Duration, binaryStarting <-chan struct{},
) chan struct{}

func SetupFakeHyprEventsServer

func SetupFakeHyprEventsServer(ctx context.Context, t *testing.T, listener net.Listener, events []string) chan struct{}

func SetupFakeHyprEventsServerWithSleep added in v1.3.2

func SetupFakeHyprEventsServerWithSleep(ctx context.Context, t *testing.T, listener net.Listener,
	events []string, initialSleep *time.Duration, sleepBetweenEvents time.Duration,
) chan struct{}

func SetupFakeHyprIPCWriter

func SetupFakeHyprIPCWriter(t *testing.T, listener net.Listener, responseData [][]byte,
	expectedCommands []string, exitOnError bool,
) chan struct{}

func SetupHyprEnvVars

func SetupHyprEnvVars(t *testing.T) (string, string)

func SetupHyprSocket

func SetupHyprSocket(ctx context.Context, t *testing.T, xdgRuntimeDir, signature string,
	hyprSocketFun func(string, string) string,
) (net.Listener, func())

func UpdateFixture

func UpdateFixture(t *testing.T, targetFile, fixtureFile string)

Types

type FinalOpt added in v1.3.2

type FinalOpt func(opts *FinalOpts)

func WithFinalTimeout added in v1.3.2

func WithFinalTimeout(d time.Duration) FinalOpt

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) Get

func (s *TestDbusService) Get(interfaceName, propertyName string) (dbus.Variant, *dbus.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 (t *TestModel) FinalOutput(opts ...FinalOpt) (string, error)

func (*TestModel) FinalScreen added in v1.3.2

func (t *TestModel) FinalScreen(opts ...FinalOpt) (string, error)

func (*TestModel) Read added in v1.3.2

func (t *TestModel) Read(p []byte) (n int, err error)

func (*TestModel) Send added in v1.3.2

func (t *TestModel) Send(sequence []byte) error

func (*TestModel) Type added in v1.3.2

func (t *TestModel) Type(s string) error

func (*TestModel) WaitFinished added in v1.3.2

func (t *TestModel) WaitFinished(opts ...FinalOpt) error

func (*TestModel) WaitFor added in v1.3.2

func (t *TestModel) WaitFor(condition func(bts []byte) bool, options ...WaitForOption) error

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

type WaitingForContext added in v1.3.2

type WaitingForContext struct {
	Duration      time.Duration
	CheckInterval time.Duration
}

Jump to

Keyboard shortcuts

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