testutil

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 10 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureOutput

func CaptureOutput(f func()) string

CaptureOutput captures stdout during function execution

func CreateTestClient

func CreateTestClient() *client.Client

CreateTestClient creates a minimal test client for unit tests

func MockDatadogContext

func MockDatadogContext() context.Context

MockDatadogContext creates a test context for Datadog API calls

func NewMockAPIResponseServer

func NewMockAPIResponseServer(responses map[string]MockAPIResponse) *httptest.Server

NewMockAPIResponseServer creates a server with multiple endpoint responses

func NewMockAPIServer

func NewMockAPIServer(response any, statusCode int) *httptest.Server

NewMockAPIServer creates a mock HTTP server that returns the specified response

func NewMockAPIServerWithHandler

func NewMockAPIServerWithHandler(handler http.HandlerFunc) *httptest.Server

NewMockAPIServerWithHandler creates a mock HTTP server with a custom handler

func NewMockClient

func NewMockClient(serverURL string) *client.Client

NewMockClient creates a mock client that uses a test HTTP server

func SimulateInput

func SimulateInput(input string) io.Reader

SimulateInput creates an io.Reader from a string for simulating stdin

Types

type MockAPIResponse

type MockAPIResponse struct {
	StatusCode int
	Body       any
	Headers    map[string]string
}

MockAPIResponse represents a mock API response for testing

type MockClient

type MockClient struct {
	*client.Client
}

MockClient provides a mock Datadog client for testing

Jump to

Keyboard shortcuts

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