-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtestdata_test.go
54 lines (47 loc) · 1.48 KB
/
testdata_test.go
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
package schema
import "testing"
func TestTestSourceColumns_Default(t *testing.T) {
// basic sanity check for tested columns
table := TestTable("test", TestSourceOptions{})
if len(table.Columns) < 73 {
t.Fatalf("expected at least 73 columns by default got: %d ", len(table.Columns))
}
// test some specific columns
checkColumnsExist(t, table.Columns, []string{"int64", "date32", "timestamp_us", "string", "struct", "string_list"})
}
func TestTestSourceColumns_SkipAll(t *testing.T) {
table := TestTable("test", TestSourceOptions{
SkipLists: true,
SkipTimestamps: true,
SkipDates: true,
SkipMaps: true,
SkipStructs: true,
SkipIntervals: true,
SkipDurations: true,
SkipTimes: true,
SkipLargeTypes: true,
})
// test some specific columns
checkColumnsExist(t, table.Columns, []string{"int64", "string"})
checkColumnsDontExist(t, table.Columns, []string{"date32", "struct", "string_map"})
}
func checkColumnsExist(t *testing.T, list ColumnList, cols []string) {
for _, col := range cols {
if list.Get(col) == nil {
t.Errorf("expected column %s to be present", col)
}
}
}
func checkColumnsDontExist(t *testing.T, list ColumnList, cols []string) {
for _, col := range cols {
if list.Get(col) != nil {
t.Errorf("expected no %s column", col)
}
}
}
func TestGenTestData(*testing.T) {
table := TestTable("test", TestSourceOptions{})
// smoke test that no panics
tg := NewTestDataGenerator(0)
_ = tg.Generate(table, GenTestDataOptions{})
}