forked from hishamkaram/geoserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage_stores_test.go
81 lines (74 loc) · 2.66 KB
/
coverage_stores_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
package geoserver
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetCoverageStores(t *testing.T) {
gsCatalog := GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
coverageStores, err := gsCatalog.GetCoverageStores("nurc")
assert.NotNil(t, coverageStores)
assert.Nil(t, err)
coverageStoresFail, errFail := gsCatalog.GetCoverageStores("dummy")
assert.Nil(t, coverageStoresFail)
assert.NotNil(t, errFail)
}
func TestGetCoverageStore(t *testing.T) {
gsCatalog := GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
coverageStore, err := gsCatalog.GetCoverageStore("nurc", "arcGridSample")
assert.NotNil(t, coverageStore)
assert.Nil(t, err)
coverageStoreFail, errFail := gsCatalog.GetCoverageStore("nurc", "dummy")
assert.Nil(t, coverageStoreFail)
assert.NotNil(t, errFail)
}
func TestCreateCoverageStores(t *testing.T) {
gsCatalog := GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
coverageStore := CoverageStore{
Name: "sfdem_test",
Description: "sfdem_test Description",
Type: "GeoTIFF",
URL: "file:data/sf/sfdem.tif",
Workspace: &Resource{
Name: "sf",
Href: "http://localhost:8080/geoserver/rest/workspaces/sf.json",
},
Enabled: true,
}
created, err := gsCatalog.CreateCoverageStore("sf", coverageStore)
assert.True(t, created)
assert.Nil(t, err)
createdFail, errFail := gsCatalog.CreateCoverageStore("dummy", CoverageStore{})
assert.False(t, createdFail)
assert.NotNil(t, errFail)
}
func TestHDeleteCoverageStore(t *testing.T) {
gsCatalog := GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
deleted, err := gsCatalog.DeleteCoverageStore("nurc", "worldImageSample", true)
assert.True(t, deleted)
assert.Nil(t, err)
deletedFail, errFail := gsCatalog.DeleteCoverageStore("nurc_dummy", "worldImageSample_dummy", true)
assert.False(t, deletedFail)
assert.NotNil(t, errFail)
}
func TestUpdateCoverageStore(t *testing.T) {
gsCatalog := GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
modified, err := gsCatalog.UpdateCoverageStore("sf", CoverageStore{
Name: "sfdem",
Description: "Updated",
})
assert.True(t, modified)
assert.Nil(t, err)
modifiedFail, errFail := gsCatalog.UpdateCoverageStore("sf_dummy", CoverageStore{
Name: "sfdem",
Description: "Updated",
})
assert.False(t, modifiedFail)
assert.NotNil(t, errFail)
}
func TestGeoserverImplemetCoverageService(t *testing.T) {
gsCatalog := reflect.TypeOf(&GeoServer{})
CoverageStoresServiceType := reflect.TypeOf((*CoverageStoresService)(nil)).Elem()
check := gsCatalog.Implements(CoverageStoresServiceType)
assert.True(t, check)
}