Versions in this module Expand all Collapse all v3 v3.0.2 Feb 4, 2023 v3.0.1 Nov 13, 2022 v3.0.0 Sep 21, 2022 Changes in this version + type Cleanable interface + Cleanup func(func()) + type Config struct + Addr string + BodyParsers []RequestBodyParser + CORS cors.Config + Context context.Context + LogVerbosity LogVerbosity + Middlewares []func(http.Handler) http.Handler + Server Server + type Configurer struct + func Configure() *Configurer + func (cb *Configurer) Addr(addr string) *Configurer + func (cb *Configurer) Build() Config + func (cb *Configurer) CORS(options ...cors.Config) *Configurer + func (cb *Configurer) Context(context context.Context) *Configurer + func (cb *Configurer) LogVerbosity(l LogVerbosity) *Configurer + func (cb *Configurer) Middlewares(fn ...func(handler http.Handler) http.Handler) *Configurer + func (cb *Configurer) RequestBodyParsers(bp ...RequestBodyParser) *Configurer + func (cb *Configurer) Server(srv Server) *Configurer + type ConsoleNotifier struct + func (n *ConsoleNotifier) Errorf(format string, args ...any) + func (n *ConsoleNotifier) FailNow() + func (n *ConsoleNotifier) Helper() + func (n *ConsoleNotifier) Logf(format string, args ...any) + type Expectation struct + Matcher expect.Matcher + Target string + ValueSelector ValueSelector + Weight weight + type LogVerbosity int + const LogSilently + const LogVerbose + type Mocha struct + func New(t T, config ...Config) *Mocha + func NewBasic() *Mocha + func (m *Mocha) AddMocks(builders ...*MockBuilder) *Scoped + func (m *Mocha) AssertCalled(t T) bool + func (m *Mocha) AssertHits(t T, expected int) bool + func (m *Mocha) AssertNotCalled(t T) bool + func (m *Mocha) Close() error + func (m *Mocha) CloseOnCleanup(t Cleanable) *Mocha + func (m *Mocha) Disable() + func (m *Mocha) Enable() + func (m *Mocha) Hits() int + func (m *Mocha) Parameters() params.P + func (m *Mocha) Start() ServerInfo + func (m *Mocha) StartTLS() ServerInfo + func (m *Mocha) Subscribe(evt hooks.Events) + func (m *Mocha) URL() string + type Mock struct + Enabled bool + Expectations []Expectation + ID int + Name string + PostActions []PostAction + Priority int + Repeat int + Reply reply.Reply + ScenarioName string + ScenarioNewState string + ScenarioRequiredState string + ScenarioState string + func (m *Mock) Called() bool + func (m *Mock) Dec() + func (m *Mock) Disable() + func (m *Mock) Enable() + func (m *Mock) Hit() + func (m *Mock) Hits() int + type MockBuilder struct + func Delete(m expect.Matcher) *MockBuilder + func Get(m expect.Matcher) *MockBuilder + func Head(m expect.Matcher) *MockBuilder + func Options(m expect.Matcher) *MockBuilder + func Patch(u expect.Matcher) *MockBuilder + func Post(m expect.Matcher) *MockBuilder + func Put(m expect.Matcher) *MockBuilder + func Request() *MockBuilder + func (b *MockBuilder) Body(matcherList ...expect.Matcher) *MockBuilder + func (b *MockBuilder) Build() *Mock + func (b *MockBuilder) FormField(field string, m expect.Matcher) *MockBuilder + func (b *MockBuilder) Header(key string, m expect.Matcher) *MockBuilder + func (b *MockBuilder) Method(method string) *MockBuilder + func (b *MockBuilder) Name(name string) *MockBuilder + func (b *MockBuilder) PostAction(action PostAction) *MockBuilder + func (b *MockBuilder) Priority(p int) *MockBuilder + func (b *MockBuilder) Query(key string, m expect.Matcher) *MockBuilder + func (b *MockBuilder) Repeat(times int) *MockBuilder + func (b *MockBuilder) Reply(rep reply.Reply) *MockBuilder + func (b *MockBuilder) ReplyFunction(fn func(*http.Request, reply.M, params.P) (*reply.Response, error)) *MockBuilder + func (b *MockBuilder) ReplyJust(status int, r ...*reply.StdReply) *MockBuilder + func (b *MockBuilder) RequestMatches(m expect.Matcher) *MockBuilder + func (b *MockBuilder) ScenarioIs(scenario string) *MockBuilder + func (b *MockBuilder) ScenarioStateIs(requiredState string) *MockBuilder + func (b *MockBuilder) ScenarioStateWillBe(newState string) *MockBuilder + func (b *MockBuilder) StartScenario(name string) *MockBuilder + func (b *MockBuilder) URL(m expect.Matcher) *MockBuilder + type PostAction interface + Run func(args PostActionArgs) error + type PostActionArgs struct + Mock *Mock + Params params.P + Request *http.Request + Response *reply.Response + type RequestBodyParser interface + CanParse func(contentType string, r *http.Request) bool + Parse func(body []byte, r *http.Request) (any, error) + type Scoped struct + func (s *Scoped) AssertCalled(t T) bool + func (s *Scoped) AssertNotCalled(t T) bool + func (s *Scoped) Called() bool + func (s *Scoped) Clean() + func (s *Scoped) Disable() + func (s *Scoped) Enable() + func (s *Scoped) Get(id int) *Mock + func (s *Scoped) Hits() int + func (s *Scoped) IsPending() bool + func (s *Scoped) ListAll() []*Mock + func (s *Scoped) ListCalled() []*Mock + func (s *Scoped) ListPending() []*Mock + type Server interface + Close func() error + Configure func(Config, http.Handler) error + Info func() ServerInfo + Start func() (ServerInfo, error) + StartTLS func() (ServerInfo, error) + type ServerInfo struct + URL string + type T interface + Errorf func(string, ...any) + FailNow func() + Helper func() + Logf func(string, ...any) + func NewConsoleNotifier() T + type ValueSelector func(r *expect.RequestInfo) any Other modules containing this package github.com/vitorsalgado/mocha github.com/vitorsalgado/mocha/v2