-
Notifications
You must be signed in to change notification settings - Fork 6
/
layer_test.go
64 lines (54 loc) · 1.8 KB
/
layer_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
package tilenol
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreateLayerMultipleSources(t *testing.T) {
config := LayerConfig{
Source: SourceConfig{
Elasticsearch: new(ElasticsearchConfig),
PostGIS: new(PostGISConfig),
},
}
_, err := CreateLayer(config)
assert.Equal(t, MultipleSourcesErr, err, "Expected to fail due to multiple sources for layer")
}
func TestCreateLayerNoSources(t *testing.T) {
config := LayerConfig{
Source: SourceConfig{},
}
_, err := CreateLayer(config)
assert.Equal(t, NoSourcesErr, err, "Expected to fail due to no sources for layer")
}
func TestLayerHashesSame(t *testing.T) {
layer := &Layer{Name: "a", source: &NilSource{}}
layer2 := &Layer{Name: "a", source: &NilSource{}}
assert.Equal(t, layer.Hash(), layer2.Hash(), "Excepted identical layers to have the same hash")
}
func TestLayerHashesDifferent(t *testing.T) {
layer := &Layer{Name: "a", source: &NilSource{}}
layer2 := &Layer{Name: "b", source: &NilSource{}}
assert.NotEqual(t, layer.Hash(), layer2.Hash(), "Excepted different layers to have a different hash")
}
func TestCreateLayerMinZoomOutOfBounds(t *testing.T) {
config := LayerConfig{
Minzoom: MinZoom - 1,
Maxzoom: MaxZoom - 1,
Source: SourceConfig{
Elasticsearch: new(ElasticsearchConfig),
},
}
_, err := CreateLayer(config)
assert.Equal(t, LayerMinZoomOutOfBoundsErr, err, "Expected to fail because layer min zoom is less than absolute allowed min")
}
func TestCreateLayerMaxZoomOutOfBounds(t *testing.T) {
config := LayerConfig{
Minzoom: MinZoom + 1,
Maxzoom: MaxZoom + 1,
Source: SourceConfig{
Elasticsearch: new(ElasticsearchConfig),
},
}
_, err := CreateLayer(config)
assert.Equal(t, LayerMaxZoomOutOfBoundsErr, err, "Expected to fail because layer max zoom is greater than absolute allowed max")
}