mock

package
v0.0.0-...-0202a88 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxMockNum  = 100
	MaxPollNum  = 100
	FakeTokenID = "0123456789abcdef01234567890abcdef"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

type Mock struct {
	Request        RequestDetail    `yaml:"request"`
	Response       ResponseDetail   `yaml:"response"`
	ExpectedStatus []string         `yaml:"expectedStatus"`
	NewStatus      string           `yaml:"newStatus"`
	Counter        PollingCondition `yaml:"counter"`
	Tracker        *Tracker
}

type MockController

type MockController struct {
	Mocks    map[string][]Mock //key should be API path
	Trackers map[string]*Tracker
	Mux      *http.ServeMux
	Server   *httptest.Server
}

func NewMockController

func NewMockController() *MockController

func (MockController) Endpoint

func (mc MockController) Endpoint() string

func (*MockController) Register

func (mc *MockController) Register(t *testing.T, trackKey string, path string, mockdata string)

func (MockController) StartServer

func (mc MockController) StartServer(t *testing.T)

func (*MockController) TerminateMockControllerSafety

func (mc *MockController) TerminateMockControllerSafety()

type PollingCondition

type PollingCondition struct {
	MinSize int `yaml:"min"`
	MaxSize int `yaml:"max"`
}

Polling Condition is used for status transition, e.g. PENDING_CREATE to ACTIVE

type RequestDetail

type RequestDetail struct {
	Method string     `yaml:"method"`
	Query  url.Values `yaml:"query"`
	Body   string     `yaml:"body"`
}

type ResponseDetail

type ResponseDetail struct {
	Code int    `yaml:"code"`
	Body string `yaml:"body"`
}

type Tracker

type Tracker struct {
	Status      string
	PollCounter int
}

Jump to

Keyboard shortcuts

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