Repository navigation
Expand file tree
/
Copy pathassert_empty_test.go
More file actions
70 lines (67 loc) · 1.61 KB
/
Copy pathassert_empty_test.go
File metadata and controls
70 lines (67 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package testing_test
import (
"errors"
"testing"
"github.com/influxdata/flux"
"github.com/influxdata/flux/execute"
"github.com/influxdata/flux/execute/executetest"
fluxtesting "github.com/influxdata/flux/stdlib/testing"
)
func TestAssertEmpty_Process(t *testing.T) {
testCases := []struct {
name string
data []flux.Table
want []*executetest.Table
wantErr error
}{
{
name: "no tables",
data: []flux.Table{},
want: []*executetest.Table(nil),
},
{
name: "all empty tables",
data: []flux.Table{&executetest.Table{
KeyCols: []string{"t1"},
ColMeta: []flux.ColMeta{
{Label: "_time", Type: flux.TTime},
{Label: "_value", Type: flux.TFloat},
{Label: "t1", Type: flux.TString},
{Label: "t2", Type: flux.TString},
},
Data: [][]interface{}{},
}},
want: []*executetest.Table(nil),
},
{
name: "non-empty table",
data: []flux.Table{&executetest.Table{
KeyCols: []string{"t1"},
ColMeta: []flux.ColMeta{
{Label: "_time", Type: flux.TTime},
{Label: "_value", Type: flux.TFloat},
{Label: "t1", Type: flux.TString},
{Label: "t2", Type: flux.TString},
},
Data: [][]interface{}{
{execute.Time(0), 7.0, "a", "y"},
},
}},
wantErr: errors.New("found 1 tables that were not empty"),
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
executetest.ProcessTestHelper(
t,
tc.data,
tc.want,
tc.wantErr,
func(d execute.Dataset, c execute.TableBuilderCache) execute.Transformation {
return fluxtesting.NewAssertEmptyTransformation(d, c)
},
)
})
}
}