definition

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2016 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	BodyAppend string `json:"bodyAppend"` // text or JSON to be appended to the body

	// 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 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 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 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
	Request  Request  `json:"request"`
	Response Response `json:"response"`
	Persist  Persist  `json:"persist"`
	Control  struct {
		Priority     int    `json:"priority"`
		Delay        int    `json:"delay"`
		Crazy        bool   `json:"crazy"`
		ProxyBaseURL string `json:"proxyBaseURL"`
	} `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 Persist

type Persist struct {
	Name   string         `json:"name"`
	Delete bool           `json:"delete"`
	AMQP   AMQPPublishing `json:"amqp"`
}

type Persisted

type Persisted struct {
	Name     string `json:"name"`
	NotFound struct {
		StatusCode int    `json:"statusCode"`
		Body       string `json:"body"`
		BodyAppend string `json:"BodyAppend"`
	} `json:"notFound"`
	BodyAppend string `json:"BodyAppend"`
}

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"`

	Body string `json:"body"`
	// contains filtered or unexported fields
}

type Response

type Response struct {
	StatusCode int `json:"statusCode"`

	Persisted  Persisted `json:"persisted"`
	Body       string    `json:"body"`
	BodyAppend string    `json:"BodyAppend"`
	// contains filtered or unexported fields
}

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
y or Y : Canonical URL