testutil

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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