Help us shape the future of Go! Take the 2026 Go Developer Survey

testutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertLogContains

func AssertLogContains(t *testing.T, output string, expected []string)

AssertLogContains checks if the output contains all expected strings

func AssertRequestHeader

func AssertRequestHeader(t *testing.T, req RecordedRequest, header, expected string)

AssertRequestHeader verifies a request has the expected header value

func AssertRequestMethodAndPath

func AssertRequestMethodAndPath(t *testing.T, req RecordedRequest, method, path string)

AssertRequestMethodAndPath verifies a request has the expected method and path

func DumpRequests

func DumpRequests(t *testing.T, requests []RecordedRequest)

DumpRequests prints all recorded requests for debugging

func JSON

func JSON(w http.ResponseWriter, status int, v any)

JSON helpers

func MockSuccessResponse

func MockSuccessResponse() http.HandlerFunc

MockSuccessResponse returns a handler that always returns a success response

func RunCLI

func RunCLI(t *testing.T, args []string, env []string, timeout time.Duration) (stdout, stderr string, exitErr error)

RunCLI executes the Pipeleek CLI binary with args, capturing stdout/stderr, with timeout

func StartMockServer

func StartMockServer(t *testing.T, handler http.HandlerFunc) (*httptest.Server, func() []RecordedRequest, func())

StartMockServer creates a new HTTP test server with request recording

func StartMockServerWithRecording

func StartMockServerWithRecording(t *testing.T, handler http.HandlerFunc) (*httptest.Server, func() []RecordedRequest, func())

StartMockServerWithRecording is an alias for StartMockServer for compatibility

func UseTestRules added in v1.4.0

func UseTestRules(t *testing.T)

UseTestRules isolates transport/pipeline tests from downloaded rule databases and provider verification. Detection policy is tested separately.

func WithError

func WithError(statusCode int, message string) http.HandlerFunc

WithError returns a handler that always returns an error status

Types

type RecordedRequest

type RecordedRequest struct {
	Method      string
	Path        string
	RawQuery    string
	Headers     http.Header
	Body        []byte
	ReceivedAt  time.Time
	ContentType string
}

RecordedRequest captures details of an HTTP request received by the mock server

Jump to

Keyboard shortcuts

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