testutil

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutil provides shared mock-controller test helpers for the controller and site package tests.

Index

Constants

View Source
const (
	// TestControllerID is the omadacId served by the mock controller.
	TestControllerID = "abc"
	// TestControllerVer is the controller version served by the mock controller.
	TestControllerVer = "6.2.10.18"
)

Variables

This section is empty.

Functions

func LoginCount

func LoginCount() int

LoginCount returns the total number of logins performed by mock controllers created via NewTestClient.

func NewTestClient

func NewTestClient(t *testing.T, handler http.HandlerFunc) *controller.Controller

NewTestClient starts a mock Omada controller serving /api/info, login, and the site-1 lookup, then creates a logged-in Controller. All other requests are delegated to handler. The site-1 lookup is first offered to handler; if the handler answers 404, the standard site-1 info is served so site-scoped handles can be created without every test mocking the lookup.

func WriteJSON

func WriteJSON(t *testing.T, w http.ResponseWriter, v any)

WriteJSON writes v as a JSON response body.

Types

This section is empty.

Jump to

Keyboard shortcuts

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