-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
trdsql_json1_test.go
68 lines (64 loc) · 1.33 KB
/
trdsql_json1_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package trdsql
import (
"errors"
"io"
"path/filepath"
"testing"
)
func TestJSONIndefiniteInputFile(t *testing.T) {
file, err := singleFileOpen(filepath.Join(dataDir, "test_indefinite.json"))
if err != nil {
t.Error(err)
}
jr, err := NewJSONReader(file, NewReadOpts())
if err != nil {
t.Error(`csvInputNew error`)
}
list, err := jr.Names()
if err != nil {
t.Fatalf("Names error :%s", err)
}
if len(list) != 2 {
t.Error(`invalid column`)
}
}
func TestJSONIndefiniteInputFile2(t *testing.T) {
file, err := singleFileOpen(filepath.Join(dataDir, "test_indefinite.json"))
if err != nil {
t.Error(err)
}
ro := NewReadOpts()
ro.InPreRead = 2
jr, err := NewJSONReader(file, ro)
if err != nil {
t.Error(`csvInputNew error`)
}
list, err := jr.Names()
if err != nil {
t.Fatalf("Names error :%s", err)
}
if len(list) != 3 {
t.Error(`invalid column`)
}
}
func TestJSONIndefiniteInputFile3(t *testing.T) {
file, err := singleFileOpen(filepath.Join(dataDir, "test_indefinite.json"))
if err != nil {
t.Error(err)
}
ro := NewReadOpts()
ro.InPreRead = 100
jr, err := NewJSONReader(file, ro)
if err != nil {
t.Errorf("NewJSONReader error: %s", err)
}
list, err := jr.Names()
if err != nil {
if !errors.Is(err, io.EOF) {
t.Fatalf("Names error :%s", err)
}
}
if len(list) != 4 {
t.Error(`invalid column`)
}
}