Documentation ¶
Overview ¶
Package mock defines a mock backend for testing.
Example use:
b := New(Config{ Info: func(context.Context, string) ([]types.Info, error) { return nil, errors.New("Oh no") } }) got, err := b.Info(ctx, "foo")
Index ¶
- type Backend
- func (b Backend) Contains(targets []string) bool
- func (b Backend) Find(ctx context.Context, request types.FindRequest) (types.Matches, error)
- func (b Backend) GetServerAddress() string
- func (b Backend) Info(ctx context.Context, request types.InfoRequest) ([]types.Info, error)
- func (b Backend) Logger() *zap.Logger
- func (b Backend) Render(ctx context.Context, request types.RenderRequest) ([]types.Metric, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is a mock backend.
func (Backend) GetServerAddress ¶ added in v0.2.0
type Config ¶
type Config struct { Find func(context.Context, types.FindRequest) (types.Matches, error) Info func(context.Context, types.InfoRequest) ([]types.Info, error) Render func(context.Context, types.RenderRequest) ([]types.Metric, error) Contains func([]string) bool }
Config configures a mock Backend. Define ad-hoc functions to return expected values depending on input. If a function is not defined, default to one that returns an empty response and nil error. A mock backend contains all targets by default.
Click to show internal directories.
Click to hide internal directories.