docs-v2/content/v2.0/reference/flux/functions/tests/assertequals.md

1.3 KiB

title description menu weight
assertEquals() function The assertEquals() function tests whether two streams have identical data.
v2_0_ref
name parent
assertEquals Tests
1

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

Function type: Test

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

The 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 data piped-forward from another function (<-).

Data type: Object

want

The stream that contains the expected data to test against.

Data type: Object

Examples

Assert of separate streams
want = from(bucket: "backup-telegraf/autogen")
  |> range(start: -5m)

got = from(bucket: "telegraf/autogen")
  |> range(start: -5m)

assertEquals(got: got, want: want)
Inline assertion
want = from(bucket: "backup-telegraf/autogen")
  |> range(start: -5m)

from(bucket: "telegraf/autogen")
  |> range(start: -5m)
  |> assertEquals(want: want)