Documentation

testing.assertEquals() function

Flux 0.14.0+

The testing.assertEquals() function tests whether two streams have identical data. If equal, the function outputs the tested data stream unchanged. If unequal, the function returns an error.

import "testing"

testing.assertEquals(
  name: "streamEquality",
  got: got,
  want: want
)

The testing.assertEquals() function can be used to perform in-line tests in a query.

Parameters

name

Unique name given to the assertion.

got

The stream containing data to test. Defaults to piped-forward data (<-).

want

The stream that contains the expected data to test against.

Examples

Assert of separate streams
import "testing"

want = from(bucket: "backup-example-bucket")
  |> range(start: -5m)

got = from(bucket: "example-bucket")
  |> range(start: -5m)

testing.assertEquals(got: got, want: want)
Inline assertion
import "testing"

want = from(bucket: "backup-example-bucket")
  |> range(start: -5m)

from(bucket: "example-bucket")
  |> range(start: -5m)
  |> testing.assertEquals(want: want)

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.