testing.assertEquals() function

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.

  1. import "testing"
  2. testing.assertEquals(
  3. name: "streamEquality",
  4. got: got,
  5. want: want
  6. )

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

Parameters

name

Unique name given to the assertion.

*Data type: String*

got

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

*Data type: Record*

want

The stream that contains the expected data to test against.

*Data type: Record*

Examples

Assert of separate streams
  1. import "testing"
  2. want = from(bucket: "backup-example-bucket")
  3. |> range(start: -5m)
  4. got = from(bucket: "example-bucket")
  5. |> range(start: -5m)
  6. testing.assertEquals(got: got, want: want)
Inline assertion
  1. import "testing"
  2. want = from(bucket: "backup-example-bucket")
  3. |> range(start: -5m)
  4. from(bucket: "example-bucket")
  5. |> range(start: -5m)
  6. |> testing.assertEquals(want: want)