mockserver

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mockserver exposes a Mockserver services.

Index

Constants

View Source
const (
	// ServiceName is the advertised name of this service.
	ServiceName = "mockserver"
)

Variables

This section is empty.

Functions

func NewComponent

NewComponent creates a new Redis component.

Types

type CallTimes

type CallTimes struct {
	RemainingTimes int  `json:"remainingTimes"`
	Unlimited      bool `json:"unlimited"`
}

CallTimes configures the call times for an expectation.

type Client

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

Client is a client for mockserver.

func NewClient

func NewClient(address string) *Client

NewClient creates a new client.

func (*Client) CreateExpectation

func (c *Client) CreateExpectation(expectation Expectation) error

CreateExpectation creates a new expectation (request/response) in the mockserver.

func (*Client) Reset

func (c *Client) Reset() error

Reset deletes all expectations and recorded requests in mockserver.

type Delay

type Delay struct {
	TimeUnit TimeUnit `json:"timeUnit"`
	Value    int      `json:"value"`
}

Delay representes the amount of that mockserver delays the response by.

type Expectation

type Expectation struct {
	Request  Request   `json:"httpRequest"`
	Response Response  `json:"httpResponse"`
	Times    CallTimes `json:"times"`
}

Expectation represents an expectation in mockserver.

type QueryParameter

type QueryParameter struct {
	Name   string   `json:"name"`
	Values []string `json:"values"`
}

QueryParameter is a query parameter for mockserver.

type Request

type Request struct {
	Method          string              `json:"method"`
	Path            string              `json:"path"`
	Headers         map[string][]string `json:"headers,omitempty"`
	QueryParameters []QueryParameter    `json:"queryStringParameters,omitempty"`
	Body            interface{}         `json:"body,omitempty"`
}

Request is the request that an expectation matches against.

func (Request) WithJSONBody

func (r Request) WithJSONBody(body interface{}) Request

WithJSONBody returns a Request with a JSON body set.

func (Request) WithParametersBody

func (r Request) WithParametersBody(parameters map[string][]string) Request

WithParametersBody returns a Request with a JSON body set.

type Response

type Response struct {
	Status  int                 `json:"statusCode"`
	Body    interface{}         `json:"body"`
	Delay   *Delay              `json:"delay,omitempty"`
	Headers map[string][]string `json:"headers,omitempty"`
}

Response is an untyped response from mockserver expectation.

type TimeUnit

type TimeUnit string

TimeUnit represents a time unit.

const (
	// Seconds represents the Seconds time unit.
	Seconds TimeUnit = "SECONDS"
	// Milliseconds represents the Milliseconds time unit.
	Milliseconds TimeUnit = "MILLISECONDS"
)

Jump to

Keyboard shortcuts

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