dbustest

package
v0.0.0-...-c7fba9c Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connection

func Connection(handler DBusHandlerFunc) (*dbus.Conn, error)

Connection returns a DBus connection for writing unit tests.

The handler function is called for each message sent to the bus. It can return any number of messages to send in response. The counter aids in testing a sequence of messages that is expected.

func StubConnection

func StubConnection() (*dbus.Conn, error)

StubConnection returns a dbus connection that does nothing.

Using dbustest.Connection panics as the goroutines spawned by go-dbus do not expect the connection to be immediately closed.

Types

type DBusHandlerFunc

type DBusHandlerFunc func(msg *dbus.Message, n int) ([]*dbus.Message, error)

DBusHandlerFunc is the type of handler function for interacting with test DBus.

The handler is called for each message that arrives to the bus from the test client. The handler can respond by returning zero or more messages. Typically one message is returned (method response or error). Additional messages can be returned to represent signals emitted during message handling.

The handler is not called for internal messages related to DBus itself.

Jump to

Keyboard shortcuts

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