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

1.4 KiB

title description aliases menu weight flux/v0.x/tags introduced
testing.assertEmpty() function The testing.assertEmpty() function tests if an input stream is empty.
/influxdb/v2.0/reference/flux/functions/testing/assertempty/
/influxdb/v2.0/reference/flux/stdlib/testing/assertempty/
/influxdb/cloud/reference/flux/stdlib/testing/assertempty/
flux_0_x_ref
name parent
testing.assertEmpty testing
301
tests
transformations
0.18.0

The testing.assertEmpty() function tests if an input stream is empty. If not empty, the function returns an error.

import "testing"

testing.assertEmpty()

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

Parameters

tables

Input data. Default is piped-forward data (<-).

Examples

Check if there is a difference between streams

This example uses the testing.diff() function which outputs the diff for the two streams. The .testing.assertEmpty() function checks to see if the diff is empty.

import "testing"

got = from(bucket: "example-bucket")
    |> range(start: -15m)
want = from(bucket: "backup_example-bucket")
    |> range(start: -15m)

got
    |> testing.diff(want: want)
    |> testing.assertEmpty()