definition

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFoundPath = errors.New("Configuration path not found")

ErrNotFoundPath error from missing or configuration path

Functions

This section is empty.

Types

type AMQPPublishing

type AMQPPublishing struct {
	URL        string `json:"url"`        // url to the amqp server e.g. amqp://guest:guest@localhost:5672/vhost
	RoutingKey string `json:"routingKey"` // the routing key for posting the message
	Delay      int    `json:"delay"`      // message send delay in seconds
	Exchange   string `json:"exchange"`   // the name of the exchange to post to
	Body       string `json:"body"`       // payload of the message

	// Properties
	ContentType     string    `json:"contentType"`     // MIME content type
	ContentEncoding string    `json:"contentEncoding"` // MIME content encoding
	Priority        uint8     `json:"priority"`        // 0 to 9
	CorrelationID   string    `json:"correlationId"`   // correlation identifier
	ReplyTo         string    `json:"replyTo"`         // address to to reply to (ex: RPC)
	Expiration      string    `json:"expiration"`      // message expiration spec
	MessageID       string    `json:"messageId"`       // message identifier
	Timestamp       time.Time `json:"timestamp"`       // message timestamp
	Type            string    `json:"type"`            // message type name
	UserID          string    `json:"userId"`          // creating user id - ex: "guest"
	AppID           string    `json:"appId"`           // creating application id
}

AMQPPublishing used for sending to AMQP server

type Actions added in v1.0.0

type Actions map[string]string

type ConfigReader

type ConfigReader interface {
	CanRead(filename string) bool
	Read(filename string) (Mock, error)
}

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

type Control added in v1.0.0

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

type Cookies

type Cookies map[string]string

type FileDefinition

type FileDefinition struct {
	Path          string
	Updates       chan []Mock
	ConfigReaders []ConfigReader
}

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

func NewFileDefinition

func NewFileDefinition(path string, updatesCh chan []Mock) *FileDefinition

NewFileDefinition file definition constructor

func (*FileDefinition) AddConfigReader

func (fd *FileDefinition) AddConfigReader(reader ConfigReader)

AddConfigReader allows append new readers to able load different config files

func (*FileDefinition) ReadMocksDefinition

func (fd *FileDefinition) ReadMocksDefinition() []Mock

ReadMocksDefinition reads all definitions and return an array of valid mocks

func (*FileDefinition) WatchDir

func (fd *FileDefinition) WatchDir()

WatchDir start the watching process to detect any change on defintions

type HttpHeaders added in v1.0.0

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

type JSONReader

type JSONReader struct {
}

JSONReader struct created to read json config files

func (JSONReader) CanRead

func (jp JSONReader) CanRead(filename string) bool

CanRead return true if is a json file

func (JSONReader) Read

func (jp JSONReader) Read(filename string) (Mock, error)

Read Unmarshal a json file to Mock struct

type Match

type Match struct {
	Request  Request  `json:"request"`
	Response Response `json:"response"`
	Result   Result   `json:"result"`
	Persist  Persist  `json:"persist"`
}

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

type Mock

type Mock struct {
	Name        string
	Description string   `json:"description"`
	Request     Request  `json:"request"`
	Response    Response `json:"response"`
	Persist     Persist  `json:"persist"`
	Notify      Notify   `json:"notify"`
	Control     Control  `json:"control"`
}

Mock contains the user mock definition

type NonJSONItem

type NonJSONItem struct {
	Content string `json:"non_json_content"`
}

NonJSONItem used for storing non JSON content in mongo, by saving it in a the NonJSONContent of a wrapper json content

type Notify added in v1.0.0

type Notify struct {
	Amqp AMQPPublishing `json:"amqp"`
	Http Requests       `json:"http"`
}

type Persist

type Persist struct {
	Entity     string  `json:"entity"`
	Collection string  `json:"collection"`
	Actions    Actions `json:"actions"`
	Engine     string  `json:"engine"`
}

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 {
	//ReadMockDefinition return an array of mock definitions sort by priority.
	ReadMocksDefinition() []Mock
}

Reader interface contains the funtions to obtain the mock defintions.

type Request

type Request struct {
	Method                string `json:"method"`
	Path                  string `json:"path"`
	QueryStringParameters Values `json:"queryStringParameters"`
	HttpHeaders
	Body string `json:"body"`
}

type Requests added in v1.0.0

type Requests []Request

type Response

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

type Result

type Result struct {
	Found  bool              `json:"match"`
	Errors map[string]string `json:"errors"`
}

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

type Values

type Values map[string][]string

type YAMLReader

type YAMLReader struct {
}

YAMLReader struct created to read yaml config files

func (YAMLReader) CanRead

func (jp YAMLReader) CanRead(filename string) bool

CanRead return true if is a yaml file

func (YAMLReader) Read

func (jp YAMLReader) Read(filename string) (Mock, error)

Read Unmarshal a yaml file to Mock struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL