testing.assertEmpty() function

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

*Function type: Test*

  1. import "testing"
  2. testing.assertEmpty()

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

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.

  1. import "testing"
  2. got = from(bucket: "example-bucket")
  3. |> range(start: -15m)
  4. want = from(bucket: "backup_example-bucket")
  5. |> range(start: -15m)
  6. got
  7. |> testing.diff(want: want)
  8. |> testing.assertEmpty()