test

package
v0.0.0-...-6472126 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2017 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package test provides utilities for testing the //pkg/aspect code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrEval

func NewErrEval() expr.Evaluator

NewErrEval constructs a new Evaluator that always returns an error.

func NewFakeEval

func NewFakeEval(body EvalBody) expr.Evaluator

NewFakeEval constructs a new Evaluator with the provided body.

func NewIDEval

func NewIDEval() expr.Evaluator

NewIDEval constructs a new Evaluator that return the expression string its provided.

Types

type Bag

type Bag struct {
	attribute.Bag

	Strs  map[string]string
	Times map[string]time.Time
}

Bag is a test version of attribute.Bag

func NewBag

func NewBag() *Bag

NewBag creates a new bag for testing.

func (*Bag) Bool

func (t *Bag) Bool(name string) (bool, bool)

Bool returns the named attribute if it exists.

func (*Bag) Bytes

func (t *Bag) Bytes(name string) ([]uint8, bool)

Bytes returns the named attribute if it exists.

func (*Bag) DebugString

func (t *Bag) DebugString() string

DebugString returns the empty string. TODO: use attribute.GetMutableBagForTest

func (*Bag) Duration

func (t *Bag) Duration(name string) (time.Duration, bool)

Duration returns the named attribute if it exists.

func (*Bag) Float64

func (t *Bag) Float64(name string) (float64, bool)

Float64 returns the named attribute if it exists.

func (*Bag) Int64

func (t *Bag) Int64(name string) (int64, bool)

Int64 returns the named attribute if it exists.

func (*Bag) String

func (t *Bag) String(name string) (string, bool)

String returns the named attribute if it exists.

func (*Bag) StringMap

func (t *Bag) StringMap(name string) (map[string]string, bool)

StringMap returns the named attribute if it exists.

func (*Bag) Time

func (t *Bag) Time(name string) (time.Time, bool)

Time returns the named attribute if it exists.

type DescriptorFinder

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

DescriptorFinder implements the descriptor.Finder interface more simply than the real object (namely in that it doesn't require synthesizing a config, and will panic when used incorrectly).

func NewDescriptorFinder

func NewDescriptorFinder(desc map[string]interface{}) *DescriptorFinder

NewDescriptorFinder returns a DescriptorFinder that will return values from desc when queried.

func (*DescriptorFinder) GetAttribute

GetAttribute returns the AttributeDescriptor named 'name' or nil if it does not exist in the map.

func (*DescriptorFinder) GetLog

func (d *DescriptorFinder) GetLog(name string) *dpb.LogEntryDescriptor

GetLog returns the LogEntryDescriptor named 'name' or nil if it does not exist in the map.

func (*DescriptorFinder) GetMetric

func (d *DescriptorFinder) GetMetric(name string) *dpb.MetricDescriptor

GetMetric returns the MetricDescriptor named 'name' or nil if it does not exist in the map.

func (*DescriptorFinder) GetMonitoredResource

func (d *DescriptorFinder) GetMonitoredResource(name string) *dpb.MonitoredResourceDescriptor

GetMonitoredResource returns the MonitoredResourceDescriptor named 'name' or nil if it does not exist in the map.

func (*DescriptorFinder) GetPrincipal

func (d *DescriptorFinder) GetPrincipal(name string) *dpb.PrincipalDescriptor

GetPrincipal returns the PrincipalDescriptor named 'name' or nil if it does not exist in the map.

func (*DescriptorFinder) GetQuota

func (d *DescriptorFinder) GetQuota(name string) *dpb.QuotaDescriptor

GetQuota returns the QuotaDescriptor named 'name' or nil if it does not exist in the map.

type Env

type Env struct {
	adapter.Env
}

Env provides a test environment.

type EvalBody

type EvalBody func(string, attribute.Bag) (interface{}, error)

EvalBody is a function that will be executed when expr.Evaluator.Eval and expr.Evaluator.EvalString are called.

type Logger

type Logger struct {
	adapter.AccessLogsBuilder
	adapter.ApplicationLogsBuilder

	DefaultCfg     config.AspectParams
	EntryCount     int
	Logs           []adapter.LogEntry
	AccessLogs     []adapter.LogEntry
	ErrOnNewAspect bool
	ErrOnLog       bool
	Closed         bool
}

Logger is a test struct that implements the application-logs and access-logs aspects.

func (*Logger) Close

func (t *Logger) Close() error

Close marks the logger as being closed.

func (*Logger) DefaultConfig

func (t *Logger) DefaultConfig() adapter.Config

DefaultConfig returns a default configuration struct for this adapter.

func (*Logger) Description

func (t *Logger) Description() string

Description returns a user-friendly description of this builder.

func (*Logger) Log

func (t *Logger) Log(l []adapter.LogEntry) error

Log simulates processing a batch of log entries.

func (*Logger) LogAccess

func (t *Logger) LogAccess(l []adapter.LogEntry) error

LogAccess simulates processing a batch of access log entries.

func (*Logger) Name

func (t *Logger) Name() string

Name returns the official name of this builder.

func (*Logger) NewAccessLogsAspect

func (t *Logger) NewAccessLogsAspect(adapter.Env, adapter.Config) (adapter.AccessLogsAspect, error)

NewAccessLogsAspect returns a new instance of the accessLogger aspect.

func (*Logger) NewApplicationLogsAspect

func (t *Logger) NewApplicationLogsAspect(adapter.Env, adapter.Config) (adapter.ApplicationLogsAspect, error)

NewApplicationLogsAspect returns a new instance of the Logger aspect.

func (*Logger) ValidateConfig

func (t *Logger) ValidateConfig(c adapter.Config) (ce *adapter.ConfigErrors)

ValidateConfig determines whether the given configuration meets all correctness requirements.

Jump to

Keyboard shortcuts

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