mockserver

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mockserver provides a mock Cloudflare API server for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option is a function that configures the server.

func WithPort

func WithPort(port int) Option

WithPort sets the server port.

func WithStore

func WithStore(st *store.Store) Option

WithStore sets a custom store.

type RequestLogEntry

type RequestLogEntry struct {
	Timestamp time.Time
	Method    string
	Path      string
	Body      string
}

RequestLogEntry records an API request.

type Server

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

Server is the mock Cloudflare API server.

func NewServer

func NewServer(opts ...Option) *Server

NewServer creates a new mock server.

func (*Server) ErrorInjector

func (s *Server) ErrorInjector() *injection.ErrorInjector

ErrorInjector returns the server's error injector.

func (*Server) GetRequestCount

func (s *Server) GetRequestCount(pathPrefix string) int

GetRequestCount returns the number of requests matching the given path prefix.

func (*Server) GetRequestLog

func (s *Server) GetRequestLog() []RequestLogEntry

GetRequestLog returns a copy of the request log.

func (*Server) Reset

func (s *Server) Reset()

Reset resets the server state.

func (*Server) Start

func (s *Server) Start() error

Start starts the server.

func (*Server) StartAsync

func (s *Server) StartAsync() error

StartAsync starts the server in a goroutine and waits for it to be ready.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully stops the server.

func (*Server) Store

func (s *Server) Store() *store.Store

Store returns the server's data store.

func (*Server) URL

func (s *Server) URL() string

URL returns the base URL of the server.

Directories

Path Synopsis
Package main provides the entry point for the mock Cloudflare API server.
Package main provides the entry point for the mock Cloudflare API server.
Package handlers provides HTTP handlers for the mock Cloudflare API server.
Package handlers provides HTTP handlers for the mock Cloudflare API server.
Package injection provides error injection capabilities for testing.
Package injection provides error injection capabilities for testing.
internal
store
Package store provides in-memory storage for the mock Cloudflare API server.
Package store provides in-memory storage for the mock Cloudflare API server.
Package models defines the data types for the Cloudflare API mock server.
Package models defines the data types for the Cloudflare API mock server.

Jump to

Keyboard shortcuts

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