]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | // Licensed to the Apache Software Foundation (ASF) under one |
2 | // or more contributor license agreements. See the NOTICE file | |
3 | // distributed with this work for additional information | |
4 | // regarding copyright ownership. The ASF licenses this file | |
5 | // to you under the Apache License, Version 2.0 (the | |
6 | // "License"); you may not use this file except in compliance | |
7 | // with the License. You may obtain a copy of the License at | |
8 | // | |
9 | // http://www.apache.org/licenses/LICENSE-2.0 | |
10 | // | |
11 | // Unless required by applicable law or agreed to in writing, software | |
12 | // distributed under the License is distributed on an "AS IS" BASIS, | |
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | // See the License for the specific language governing permissions and | |
15 | // limitations under the License. | |
16 | ||
17 | package main // import "github.com/apache/arrow/go/v6/arrow/ipc/cmd/arrow-json-integration-test" | |
18 | ||
19 | import ( | |
20 | "io/ioutil" | |
21 | "os" | |
22 | "testing" | |
23 | ||
24 | "github.com/apache/arrow/go/v6/arrow/internal/arrdata" | |
25 | "github.com/apache/arrow/go/v6/arrow/memory" | |
26 | ) | |
27 | ||
28 | func TestIntegration(t *testing.T) { | |
29 | tempDir, err := ioutil.TempDir("", "go-arrow-integration-") | |
30 | if err != nil { | |
31 | t.Fatal(err) | |
32 | } | |
33 | defer os.RemoveAll(tempDir) | |
34 | ||
35 | const verbose = true | |
36 | for name, recs := range arrdata.Records { | |
37 | t.Run(name, func(t *testing.T) { | |
38 | if name == "decimal128" { | |
39 | t.Skip() // FIXME(sbinet): implement full decimal128 support | |
40 | } | |
41 | mem := memory.NewCheckedAllocator(memory.NewGoAllocator()) | |
42 | defer mem.AssertSize(t, 0) | |
43 | ||
44 | af1, err := ioutil.TempFile(tempDir, "go-arrow-integration-") | |
45 | if err != nil { | |
46 | t.Fatal(err) | |
47 | } | |
48 | defer af1.Close() | |
49 | ||
50 | arrdata.WriteFile(t, af1, mem, recs[0].Schema(), recs) | |
51 | arrdata.CheckArrowFile(t, af1, mem, recs[0].Schema(), recs) | |
52 | ||
53 | aj, err := ioutil.TempFile(tempDir, "arrow-json-integration-") | |
54 | if err != nil { | |
55 | t.Fatal(err) | |
56 | } | |
57 | defer aj.Close() | |
58 | ||
59 | err = cnvToJSON(af1.Name(), aj.Name(), verbose) | |
60 | if err != nil { | |
61 | t.Fatal(err) | |
62 | } | |
63 | ||
64 | err = validate(af1.Name(), aj.Name(), verbose) | |
65 | if err != nil { | |
66 | t.Fatal(err) | |
67 | } | |
68 | ||
69 | af2, err := ioutil.TempFile(tempDir, "go-arrow-integration-") | |
70 | if err != nil { | |
71 | t.Fatal(err) | |
72 | } | |
73 | defer af2.Close() | |
74 | ||
75 | err = cnvToARROW(af2.Name(), aj.Name(), verbose) | |
76 | if err != nil { | |
77 | t.Fatal(err) | |
78 | } | |
79 | ||
80 | err = validate(af2.Name(), aj.Name(), verbose) | |
81 | if err != nil { | |
82 | t.Fatal(err) | |
83 | } | |
84 | ||
85 | af2, err = os.Open(af2.Name()) | |
86 | if err != nil { | |
87 | t.Fatal(err) | |
88 | } | |
89 | defer af2.Close() | |
90 | ||
91 | arrdata.CheckArrowFile(t, af2, mem, recs[0].Schema(), recs) | |
92 | }) | |
93 | } | |
94 | } |