testutil

package
v0.0.0-...-b4459b0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package testutil provides testing utilities and mock implementations for the Boomi SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestClient

func NewTestClient(baseURL string) *client.Client

NewTestClient creates a new test client with the given base URL.

Types

type AssertRequest

type AssertRequest struct {
	Method      string
	Path        string
	Body        interface{}
	Headers     map[string]string
	QueryParams map[string]string
}

AssertRequest provides utilities for asserting HTTP requests.

type MockAuth

type MockAuth struct{}

MockAuth is a mock authenticator for testing.

func (*MockAuth) Authenticate

func (m *MockAuth) Authenticate(req *http.Request) error

Authenticate implements the Authenticator interface.

func (*MockAuth) Type

func (m *MockAuth) Type() string

Type returns the authentication type.

type MockServer

type MockServer struct {
	// contains filtered or unexported fields
}

MockServer provides a mock HTTP server for testing.

func NewMockServer

func NewMockServer() *MockServer

NewMockServer creates a new mock server.

func (*MockServer) BaseURL

func (ms *MockServer) BaseURL() string

URL returns the mock server's base URL for creating clients.

func (*MockServer) Close

func (ms *MockServer) Close()

Close closes the mock server.

func (*MockServer) On

func (ms *MockServer) On(method, path string, handler http.HandlerFunc)

On registers a handler for a specific method and path.

func (*MockServer) OnError

func (ms *MockServer) OnError(method, path string, statusCode int, message string)

OnError registers an error handler.

func (*MockServer) OnGet

func (ms *MockServer) OnGet(path string, response interface{})

OnGet registers a GET handler.

func (*MockServer) OnPost

func (ms *MockServer) OnPost(path string, response interface{})

OnPost registers a POST handler.

func (*MockServer) URL

func (ms *MockServer) URL() string

URL returns the mock server URL.

type RequestCapture

type RequestCapture struct {
	Requests []*http.Request
	Bodies   [][]byte
}

RequestCapture captures HTTP requests for testing.

func NewRequestCapture

func NewRequestCapture() *RequestCapture

NewRequestCapture creates a new request capture.

func (*RequestCapture) CaptureHandler

func (rc *RequestCapture) CaptureHandler(next http.HandlerFunc) http.HandlerFunc

CaptureHandler returns an HTTP handler that captures requests.

func (*RequestCapture) LastBody

func (rc *RequestCapture) LastBody() []byte

LastBody returns the last captured request body.

func (*RequestCapture) LastRequest

func (rc *RequestCapture) LastRequest() *http.Request

LastRequest returns the last captured request.

func (*RequestCapture) Reset

func (rc *RequestCapture) Reset()

Reset clears all captured requests.

Jump to

Keyboard shortcuts

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