telegraf: github.com/mikif70/telegraf/testutil Index | Files

package testutil

import "github.com/mikif70/telegraf/testutil"

Index

Package Files

accumulator.go testutil.go

func GetLocalHost Uses

func GetLocalHost() string

GetLocalHost returns the DOCKER_HOST environment variable, parsing out any scheme or ports so that only the IP address is returned.

func MockMetrics Uses

func MockMetrics() []telegraf.Metric

MockMetrics returns a mock []telegraf.Metric object for using in unit tests of telegraf output sinks.

func TestMetric Uses

func TestMetric(value interface{}, name ...string) telegraf.Metric

TestMetric Returns a simple test point:

measurement -> "test1" or name
tags -> "tag1":"value1"
value -> value
time -> time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)

type Accumulator Uses

type Accumulator struct {
    sync.Mutex

    Metrics []*Metric
    Errors  []error
    // contains filtered or unexported fields
}

Accumulator defines a mocked out accumulator

func (*Accumulator) Add Uses

func (a *Accumulator) Add(
    measurement string,
    value interface{},
    tags map[string]string,
    t ...time.Time,
)

Add adds a measurement point to the accumulator

func (*Accumulator) AddError Uses

func (a *Accumulator) AddError(err error)

AddError appends the given error to Accumulator.Errors.

func (*Accumulator) AddFields Uses

func (a *Accumulator) AddFields(
    measurement string,
    fields map[string]interface{},
    tags map[string]string,
    timestamp ...time.Time,
)

AddFields adds a measurement point with a specified timestamp.

func (*Accumulator) AssertContainsFields Uses

func (a *Accumulator) AssertContainsFields(
    t *testing.T,
    measurement string,
    fields map[string]interface{},
)

func (*Accumulator) AssertContainsTaggedFields Uses

func (a *Accumulator) AssertContainsTaggedFields(
    t *testing.T,
    measurement string,
    fields map[string]interface{},
    tags map[string]string,
)

func (*Accumulator) Debug Uses

func (a *Accumulator) Debug() bool

func (*Accumulator) DisablePrecision Uses

func (a *Accumulator) DisablePrecision()

func (*Accumulator) Get Uses

func (a *Accumulator) Get(measurement string) (*Metric, bool)

Get gets the specified measurement point from the accumulator

func (*Accumulator) HasFloatField Uses

func (a *Accumulator) HasFloatField(measurement string, field string) bool

HasFloatValue returns true if the given measurement has a float value

func (*Accumulator) HasIntField Uses

func (a *Accumulator) HasIntField(measurement string, field string) bool

HasIntValue returns true if the measurement has an Int value

func (*Accumulator) HasMeasurement Uses

func (a *Accumulator) HasMeasurement(measurement string) bool

HasMeasurement returns true if the accumulator has a measurement with the given name

func (*Accumulator) HasUIntField Uses

func (a *Accumulator) HasUIntField(measurement string, field string) bool

HasUIntValue returns true if the measurement has a UInt value

func (*Accumulator) NFields Uses

func (a *Accumulator) NFields() int

NFields returns the total number of fields in the accumulator, across all measurements

func (*Accumulator) SetDebug Uses

func (a *Accumulator) SetDebug(debug bool)

func (*Accumulator) SetPrecision Uses

func (a *Accumulator) SetPrecision(precision, interval time.Duration)

type Metric Uses

type Metric struct {
    Measurement string
    Tags        map[string]string
    Fields      map[string]interface{}
    Time        time.Time
}

Metric defines a single point measurement

func (*Metric) String Uses

func (p *Metric) String() string

Package testutil imports 11 packages (graph). Updated 2017-06-10. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).