testing.load() 函数
testing.load() 从表的流中加载测试数据。
函数类型签名
(<-tables: A) => A
有关更多信息,请参见 Function type signatures。
参数
表格
输入数据。默认是管道转发数据 (<-).
示例
在测试用例中加载原始表流
以下测试使用 array.from() 创建两个表流以进行比较测试。
import "testing"
import "array"
got =
array.from(
rows: [
{_time: 2021-01-01T00:00:00Z, _measurement: "m", _field: "t", _value: 1.2},
{_time: 2021-01-01T01:00:00Z, _measurement: "m", _field: "t", _value: 0.8},
{_time: 2021-01-01T02:00:00Z, _measurement: "m", _field: "t", _value: 3.2},
],
)
want =
array.from(
rows: [
{_time: 2021-01-01T00:00:00Z, _measurement: "m", _field: "t", _value: 1.2},
{_time: 2021-01-01T01:00:00Z, _measurement: "m", _field: "t", _value: 0.8},
{_time: 2021-01-01T02:00:00Z, _measurement: "m", _field: "t", _value: 3.1},
],
)
testing.load(tables: got)
|> testing.diff(want: want)