match

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCookiesNotMatch  = errors.New("Cookies not match")
	ErrScenarioNotMatch = errors.New("Scenario state not match")
	ErrPathNotMatch     = errors.New("Path not match")
)

Functions

This section is empty.

Types

type Error

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

Error contains the tested uri and the match error

type InMemoryScenarioStore

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

func NewInMemoryScenarioStore

func NewInMemoryScenarioStore() *InMemoryScenarioStore

func (*InMemoryScenarioStore) GetPaused

func (sm *InMemoryScenarioStore) GetPaused() bool

func (*InMemoryScenarioStore) GetState

func (sm *InMemoryScenarioStore) GetState(name string) string

func (*InMemoryScenarioStore) List added in v3.0.2

func (sm *InMemoryScenarioStore) List() string

func (*InMemoryScenarioStore) Reset

func (sm *InMemoryScenarioStore) Reset(name string) bool

func (*InMemoryScenarioStore) ResetAll

func (sm *InMemoryScenarioStore) ResetAll()

func (*InMemoryScenarioStore) SetPaused

func (sm *InMemoryScenarioStore) SetPaused(newstate bool)

func (*InMemoryScenarioStore) SetState

func (sm *InMemoryScenarioStore) SetState(name, status string)

type InMemoryTransactionStore

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

InMemoryTransactionStore stores all received request and their matches in memory until the last reset

func NewInMemoryTransactionStore

func NewInMemoryTransactionStore(checker Matcher, limit int) *InMemoryTransactionStore

NewInMemoryScenarioStore is the InMemoryTransactionStore constructor

func (*InMemoryTransactionStore) Get

func (mrs *InMemoryTransactionStore) Get(limit int, offset int) []Transaction

Get return an subset of current matches (positive and negative) in memory

func (*InMemoryTransactionStore) GetAll

func (mrs *InMemoryTransactionStore) GetAll() []Transaction

GetAll return current matches (positive and negative) in memory

func (*InMemoryTransactionStore) Reset

func (mrs *InMemoryTransactionStore) Reset()

Reset clean the request stored in memory

func (*InMemoryTransactionStore) ResetMatch

func (mrs *InMemoryTransactionStore) ResetMatch(req mock.Request)

ResetMatch clean the request stored in memory that matches a particular criteria

func (*InMemoryTransactionStore) Save

func (mrs *InMemoryTransactionStore) Save(req Transaction)

Save store a match information

type Matcher

type Matcher interface {
	Match(req *mock.Request, mock *mock.Definition, scenarioAware bool) (bool, error)
}

Matcher checks if the received request matches with some specific mock request config.

type Request

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

func NewTester

func NewTester(comparator *payload.Comparator, scenario ScenearioStorer) *Request

func (Request) Match

func (mm Request) Match(req *mock.Request, mock *mock.Definition, scenarioAware bool) (bool, error)

func (Request) ValuesToString

func (mm Request) ValuesToString(values mock.Values) string

type Result

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

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

type ScenearioStorer

type ScenearioStorer interface {
	SetState(name, status string)
	GetState(name string) string
	Reset(name string) bool
	ResetAll()
	SetPaused(newstate bool)
	GetPaused() bool
	List() string
}

type Spy

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

func NewSpy

func NewSpy(checker Matcher, transactionStore TransactionStorer) *Spy

func (Spy) Find

func (mc Spy) Find(r mock.Request) []Transaction

func (Spy) Get

func (mc Spy) Get(limit int, offset int) []Transaction

func (Spy) GetAll

func (mc Spy) GetAll() []Transaction

func (Spy) GetMatched

func (mc Spy) GetMatched() []Transaction

func (Spy) GetUnMatched

func (mc Spy) GetUnMatched() []Transaction

func (Spy) Reset

func (mc Spy) Reset()

func (Spy) ResetMatch

func (mc Spy) ResetMatch(r mock.Request)

ResetMatch ...

func (Spy) Save

func (mc Spy) Save(match Transaction)

type Transaction

type Transaction struct {
	Time     int64          `json:"time"`
	Request  *mock.Request  `json:"request"`
	Response *mock.Response `json:"response"`
	Result   *Result        `json:"result"`
}

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

func NewTransaction

func NewTransaction(request *mock.Request, response *mock.Response, result *Result) *Transaction

type TransactionSpier

type TransactionSpier interface {
	Find(mock.Request) []Transaction
	GetMatched() []Transaction
	GetUnMatched() []Transaction
	TransactionStorer
}

type TransactionStorer

type TransactionStorer interface {
	Save(Transaction)
	Reset()
	ResetMatch(mock.Request)
	GetAll() []Transaction
	Get(limit int, offset int) []Transaction
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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