definition

package
v2.5.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFilePathIsNotUnderConfigPath = errors.New("File path is not under config path")
View Source
var ErrInvalidMockDefinition = errors.New("Invalid mock definition")

ErrInvalidMockDefinition the file contains an invalid mock definition

View Source
var ErrMockDoesntExist = errors.New("Mock doesn't exist")
View Source
var ErrNotValidParserFound = errors.New("Not valid config reader found")

ErrNotValidParserFound we don't have any config reader valid for this file

Functions

This section is empty.

Types

type ConfigMapper

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

ConfigMapper this struct contains the path of definition and some config readers

func NewConfigMapper

func NewConfigMapper() *ConfigMapper

NewConfigMapper file definition constructor

func (*ConfigMapper) AddConfigParser

func (fd *ConfigMapper) AddConfigParser(reader Parser)

AddConfigParser allows append new readers to able load different config files

func (*ConfigMapper) Read

func (fd *ConfigMapper) Read(filename string) (Mock, error)

func (*ConfigMapper) Write

func (fd *ConfigMapper) Write(filename string, mock Mock) error

type ConfigMapping

type ConfigMapping struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewConfigMapping

func NewConfigMapping(path string, mapper *ConfigMapper, fsUpdate chan struct{}) *ConfigMapping

func (*ConfigMapping) Delete

func (fm *ConfigMapping) Delete(URI string) error

func (*ConfigMapping) Get

func (fm *ConfigMapping) Get(URI string) (Mock, bool)

func (*ConfigMapping) List

func (fm *ConfigMapping) List() []Mock

func (*ConfigMapping) Set

func (fm *ConfigMapping) Set(URI string, mock Mock) error

type Control added in v1.0.1

type Control struct {
	Priority     int      `json:"priority"`
	Delay        int      `json:"delay"`
	Crazy        bool     `json:"crazy"`
	Scenario     Scenario `json:"scenario"`
	ProxyBaseURL string   `json:"proxyBaseURL"`
	WebHookURL   string   `json:"webHookURL"`
}

type Cookies

type Cookies map[string]string

type FileWatcher

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

func NewFileWatcher

func NewFileWatcher(path string, fsUpdate chan struct{}) *FileWatcher

func (*FileWatcher) Bind

func (fw *FileWatcher) Bind()

Bind start the watching process to detect any change on defintions

func (*FileWatcher) UnBind

func (fw *FileWatcher) UnBind()

type HttpHeaders added in v1.0.1

type HttpHeaders struct {
	Headers Values  `json:"headers"`
	Cookies Cookies `json:"cookies"`
}

type Mapping

type Mapping interface {
	Set(URI string, mock Mock) error
	Delete(URI string) error
	Get(URI string) (Mock, bool)
	List() []Mock
}

type Match

type Match struct {
	Time     int64        `json:"time"`
	Request  *Request     `json:"request"`
	Response *Response    `json:"response"`
	Result   *MatchResult `json:"result"`
}

Match contains the whole information about the request match. The http request, the final response received and the matching result.

type MatchError

type MatchError struct {
	URI    string `json:"uri"`
	Reason string `json:"reason"`
}

MatchError contains the tested uri and the match error

type MatchResult

type MatchResult struct {
	Found  bool         `json:"match"`
	URI    string       `json:"uri"`
	Errors []MatchError `json:"errors"`
}

MatchResult contains the match result and the failing matches with different mocks and the reason or the fail.

type Mock

type Mock struct {
	URI         string
	Description string   `json:"description"`
	Request     Request  `json:"request"`
	Response    Response `json:"response"`
	Control     Control  `json:"control"`
}

Mock contains the user mock definition

type Parser

type Parser interface {
	CanParse(filename string) bool
	Parse(content []byte) (Mock, error)
}

Parser interface allows recognize if there is available some config reader for an a specific file.

type PrioritySort

type PrioritySort []Mock

PrioritySort mock array sorted by priority

func (PrioritySort) Len

func (s PrioritySort) Len() int

func (PrioritySort) Less

func (s PrioritySort) Less(i, j int) bool

func (PrioritySort) Swap

func (s PrioritySort) Swap(i, j int)

type Reader

type Reader interface {
	Read(string) (Mock, error)
}

Reader interface contains the funtions to obtain the mock defintions.

type Request

type Request struct {
	Scheme                string `json:"scheme"`
	Host                  string `json:"host"`
	Port                  string `json:"port"`
	Method                string `json:"method"`
	Path                  string `json:"path"`
	QueryStringParameters Values `json:"queryStringParameters"`
	Fragment              string `json:"fragment"`
	HttpHeaders
	Body string `json:"body"`
}

type Response

type Response struct {
	StatusCode int `json:"statusCode"`
	HttpHeaders
	Body string `json:"body"`
}

type Scenario

type Scenario struct {
	Name          string   `json:"name"`
	RequiredState []string `json:"requiredState"`
	NewState      string   `json:"newState"`
}

type Values

type Values map[string][]string

type Watcher

type Watcher interface {
	Bind()
	UnBind()
}

Watcher interface contains the function watching process

type Writer

type Writer interface {
	Write(string, Mock) error
}

Writer interface contains the function persiste mock definitions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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