-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathload_test.go
83 lines (68 loc) · 1.57 KB
/
load_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package osmzen
import (
"testing"
"github.com/paulmach/orb/maptile"
"github.com/paulmach/osmzen/filter"
"github.com/paulmach/osm"
"github.com/pkg/errors"
)
func TestLoadEmbeddedConfig(t *testing.T) {
config, err := LoadEmbeddedConfig(func(name string) ([]byte, error) {
return DefaultConfig.ReadFile("config/" + name)
})
if err != nil {
if err, ok := errors.Cause(err).(*filter.CompileError); ok {
t.Log(err.Error())
t.Logf("yaml: \n%s", err.YAML())
t.Logf("%+v", err.Cause)
}
t.Fatalf("load error: %v", err)
}
testConfig(t, config)
}
func TestLoadDefaultConfig(t *testing.T) {
config, err := LoadDefaultConfig()
if err != nil {
if err, ok := errors.Cause(err).(*filter.CompileError); ok {
t.Log(err.Error())
t.Logf("yaml: \n%s", err.YAML())
t.Logf("%+v", err.Cause)
}
t.Fatalf("load error: %v", err)
}
testConfig(t, config)
}
func TestLoad(t *testing.T) {
config, err := Load("config/queries.yaml")
if err != nil {
if err, ok := errors.Cause(err).(*filter.CompileError); ok {
t.Log(err.Error())
t.Logf("yaml: \n%s", err.YAML())
t.Logf("%+v", err.Cause)
}
t.Fatalf("load error: %v", err)
}
testConfig(t, config)
}
func testConfig(t *testing.T, config *Config) {
o := &osm.OSM{
Ways: osm.Ways{
{
ID: 123,
Tags: osm.Tags{
{Key: "building", Value: "yes"},
},
Nodes: osm.WayNodes{
{Lat: 0, Lon: 0},
{Lat: 1, Lon: 0},
{Lat: 1, Lon: 1},
{Lat: 0, Lon: 1},
{Lat: 0, Lon: 0},
},
},
},
}
for i := 10; i < 18; i++ {
config.Process(o, maptile.New(1, 2, 3).Bound(), 3)
}
}