testing

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMockRegistration

func CreateMockRegistration(
	t *testing.T,
	name string,
	cf func(o *device.CreateOptions) usb.Device,
	h api.StreamHandlerFunc,
) api.DeviceRegistration

func ExecCmd

func ExecCmd(t *testing.T, addr string, cmd string) string

ExecCmd dials the API server, sends cmd and reads the full response. The command should not include a trailing newline. Returns the response without the trailing newline.

func ExecuteLine

func ExecuteLine(t *testing.T, r *api.Router, data string) string

ExecuteLine routes a command string through the provided router, emulating ApiServer.handleConn logic but without network IO. The data parameter is the full request data (path + optional payload). Returns the full response as produced by the API contract.

func StartAPIServer

func StartAPIServer(t *testing.T, register func(r *api.Router, s *usb.Server, apiSrv *api.Server)) (addr string, srv *usb.Server, done func())

StartAPIServer starts an API server on a free port and calls register to allow the caller to register the handlers needed for the test. Returns the address and a function to call when done.

Types

This section is empty.

Jump to

Keyboard shortcuts

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