docs-v2/content/flux/v0.x/stdlib/testing/_index.md

2.4 KiB

title list_title description aliases menu weight flux/v0.x/tags introduced
Flux testing package testing package The Flux `testing` package provide functions for testing Flux operations. Import the `testing` package.
/influxdb/v2.0/reference/flux/functions/testing/
/influxdb/v2.0/reference/flux/stdlib/testing/
/influxdb/cloud/reference/flux/stdlib/testing/
flux_0_x_ref
name parent
testing Standard library
11
testing
functions
package
0.112.0

The Flux testing package provide functions for testing Flux operations. Import the testing package:

import "testing"

Options

The testing package includes the following options:

import "testing"

option testing.load = (tables=<-) => tables
option testing.loadMem = (csv) => c.from(csv: csv)
option testing.loadStorage = (csv) => c.from(csv: csv)
    |> range(start: 1800-01-01T00:00:00Z, stop: 2200-12-31T11:59:59Z)
    |> map(
        fn: (r) => ({r with
            _field: if exists r._field then r._field else die(msg: "test input table does not have _field column"),
            _measurement: if exists r._measurement then r._measurement else die(msg: "test input table does not have _measurement column"),
            _time: if exists r._time then r._time else die(msg: "test input table does not have _time column"),
        }),
    )

load

Function option that loads tests data from a stream of tables. Default is:

(tables=<-) => tables

loadMem

Function option that loads annotated CSV test data from memory to emulate query results returned by Flux. Default is:

(csv) => c.from(csv: csv)

loadStorage

Function option that loads annotated CSV test data as if queried from InfluxDB. Ensures tests behave correctly in both the Flux and InfluxDB test suites. Default is:

(csv) => c.from(csv: csv)
    |> range(start: 1800-01-01T00:00:00Z, stop: 2200-12-31T11:59:59Z)
    |> map(
        fn: (r) => ({r with
            _field: if exists r._field then r._field else die(msg: "test input table does not have _field column"),
            _measurement: if exists r._measurement then r._measurement else die(msg: "test input table does not have _measurement column"),
            _time: if exists r._time then r._time else die(msg: "test input table does not have _time column"),
        }),
    )

Functions

{{< children type="functions" show="pages" >}}