MCPcopy Create free account
hub / github.com/AdRoll/baker / TestNotNull

Function TestNotNull

filter/notnull_test.go:10–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestNotNull(t *testing.T) {
11 tests := []struct {
12 record string
13 fields []string
14 want bool // true: kept, false: discarded
15 wantErr bool
16 }{
17 {
18 record: "abc,def,ghi",
19 fields: nil,
20 want: true,
21 },
22 {
23 record: "abc,def,ghi",
24 fields: []string{"foo", "non-existent"},
25 wantErr: true,
26 },
27 {
28 record: "abc,def,ghi",
29 fields: []string{},
30 want: true,
31 },
32 {
33 record: "abc,def,ghi",
34 fields: []string{"foo"},
35 want: true,
36 },
37 {
38 record: "abc,def,",
39 fields: []string{"foo"},
40 want: true,
41 },
42 {
43 record: "abc,def,",
44 fields: []string{"foo", "bar", "baz"},
45 want: false,
46 },
47 {
48 record: "abc,,ghi",
49 fields: []string{"bar"},
50 want: false,
51 },
52 }
53
54 fieldByName := func(name string) (baker.FieldIndex, bool) {
55 switch name {
56 case "foo":
57 return 0, true
58 case "bar":
59 return 1, true
60 case "baz":
61 return 2, true
62 }
63 return 0, false
64 }
65
66 for _, tt := range tests {
67 t.Run(strings.Join(tt.fields, ","), func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

ParseMethod · 0.95
ProcessMethod · 0.95
NewNotNullFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected