-
Notifications
You must be signed in to change notification settings - Fork 1
/
multi_test.go
68 lines (48 loc) · 1.1 KB
/
multi_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 reader
import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"testing"
)
func TestMultiReader(t *testing.T) {
ctx := context.Background()
cwd, err := os.Getwd()
if err != nil {
t.Fatalf("Failed to determine current working directory, %v", err)
}
uris := []string{
fmt.Sprintf("fs://%s/fixtures", cwd),
"null://",
}
readers := make([]Reader, len(uris))
for idx, u := range uris {
r, err := NewReader(ctx, u)
if err != nil {
t.Fatalf("Failed to create reader for '%s', %v", u, err)
}
readers[idx] = r
}
mr, err := NewMultiReader(ctx, readers...)
if err != nil {
t.Fatalf("Failed to create new multi reader, %v", err)
}
to_test := []string{
"101/736/545/101736545.geojson",
"101/736/545/101736545.geojson.bz2",
"do-not-exist.txt", // should be skipped by fs:// reader and accepted by null:// reader
}
for _, path := range to_test {
fh, err := mr.Read(ctx, path)
if err != nil {
t.Fatalf("Failed to read %s, %v", path, err)
}
defer fh.Close()
_, err = io.Copy(ioutil.Discard, fh)
if err != nil {
t.Fatalf("Failed to copy %s, %v", path, err)
}
}
}