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

1.7 KiB

title description aliases menu weight flux/v0.x/tags introduced
testing.assertEquals() function The testing.assertEquals() function tests whether two streams have identical data.
/influxdb/v2.0/reference/flux/functions/tests/assertequals
/influxdb/v2.0/reference/flux/functions/testing/assertequals/
/influxdb/v2.0/reference/flux/stdlib/testing/assertequals/
/influxdb/cloud/reference/flux/stdlib/testing/assertequals/
flux_0_x_ref
name parent
testing.assertEquals testing
301
tests
transformations
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)