-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsv_test.go
66 lines (54 loc) · 1.07 KB
/
csv_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
package harper
import (
"fmt"
"os"
"testing"
)
func TestCSVURLLoad(t *testing.T) {
schema := randomID()
table := randomID()
if err := c.CreateSchema(schema); err != nil {
t.Fatal(err)
}
wait()
if err := c.CreateTable(schema, table, "id"); err != nil {
t.Log(err)
t.FailNow()
}
wait()
fd, err := os.Open("testdata/companies100.csv")
if err != nil {
t.Fatal("unable to open test data file")
}
defer fd.Close()
jobID, err := c.CSVDataLoad(schema, table, false, fd)
t.Log(fmt.Sprintf("Job ID: %s", jobID))
if err != nil {
t.Fatal(err)
}
for {
job, err := c.GetJob(jobID)
if err != nil {
t.Fatal(err)
break
}
if job.Status == JobStatusCompleted {
break
} else {
t.Log(fmt.Sprintf("Job status was: %s", job.Status))
}
wait()
}
// The table should now have 100 rows
meta, err := c.DescribeTable(schema, table)
if err != nil {
t.Fatal(err)
}
if meta.RecordCount != 100 {
t.Log(meta)
t.Fatal(fmt.Errorf("expected table to have 100 rows after csv load"))
}
if err := c.DropSchema(schema); err != nil {
t.Fatal(err)
}
}