Docs

v2.0

testing.diff() function

The testing.diff() function produces a diff between two streams.

Function type: Test

import "testing"

testing.diff(got: stream2, want: stream1)

It matches tables from each stream with the same group keys. For each matched table, it produces a diff. Any added or removed rows are added to the table as a row. An additional string column with the name diff is created and contains a - if the row was present in the got table and not in the want table or + if the opposite is true.

The diff function is guaranteed to emit at least one row if the tables are different and no rows if the tables are the same. The exact diff produced may change.

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

Parameters

got

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

Data type: Object

want

The stream that contains the expected data to test against.

Data type: Object

Examples

Diff separate streams
import "testing"

want = from(bucket: "backup-telegraf/autogen")
  |> range(start: -5m)
got = from(bucket: "telegraf/autogen")
  |> range(start: -5m)
testing.diff(got: got, want: want)
Inline diff
import "testing"

want = from(bucket: "backup-telegraf/autogen") |> range(start: -5m)
from(bucket: "telegraf/autogen")
  |> range(start: -5m)
  |> testing.diff(want: want)

Bug Reports and Feedback

Thank you for being willing to help test InfluxDB v2.0 alpha! Feedback and bug reports are welcome and encouraged both for InfluxDB and this documentation.

Submit feedback in the InfluxData Community