testutil

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package testutil provides helpers for starting the kcd daemon in tests.

Package testutil provides a mock KDE Connect peer for integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartTestDaemon

func StartTestDaemon(t *testing.T, cfg *config.Config) (context.CancelFunc, *client.Client)

StartTestDaemon starts a kcd daemon in a goroutine with a cancellable context and waits up to 3 seconds for its IPC socket to be ready. It returns a cancel function (to stop the daemon) and a pre-connected client.

Types

type MockPeer

type MockPeer struct {
	// contains filtered or unexported fields
}

MockPeer simulates a remote KDE Connect device.

func NewMockPeer

func NewMockPeer(t *testing.T, tlsConfig *tls.Config) *MockPeer

NewMockPeer creates a new MockPeer.

func (*MockPeer) Dial

func (p *MockPeer) Dial(serverAddr string) net.Conn

Dial connects to the given TCP address, completes the plaintext identity exchange, then upgrades to TLS as the TLS server (KDE Connect rule: the TCP initiator acts as TLS server).

func (*MockPeer) DialPipe

func (p *MockPeer) DialPipe() (peerConn net.Conn, serverConn net.Conn)

DialPipe creates an in-process net.Pipe pair, performs the identity exchange on the given server-side connection (serverConn), and returns the peer-side conn ready for SendPacket/ReadPacket. The caller is responsible for handling serverConn in a goroutine.

func (*MockPeer) ReadPacket

func (p *MockPeer) ReadPacket(conn net.Conn) (*protocol.Packet, error)

ReadPacket reads one newline-delimited JSON packet from conn.

func (*MockPeer) SendPacket

func (p *MockPeer) SendPacket(conn net.Conn, pkt *protocol.Packet) error

SendPacket writes a packet as newline-delimited JSON on conn.

Jump to

Keyboard shortcuts

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