-
Notifications
You must be signed in to change notification settings - Fork 24
/
datastores_test.go
106 lines (99 loc) · 3.48 KB
/
datastores_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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package geoserver
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type GeoserverDatastoreSuite struct {
suite.Suite
gsCatalog *GeoServer
}
func (suite *GeoserverDatastoreSuite) SetupSuite() {
suite.gsCatalog = GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
created, err := suite.gsCatalog.CreateWorkspace("datastores_test")
assert.True(suite.T(), created)
assert.Nil(suite.T(), err)
}
func TestGetDatastoreObj(t *testing.T) {
conn := DatastoreConnection{
Name: "datastores_test",
Port: 5432,
Host: "localhost",
Type: "postgis",
DBName: "cartoview_datastore",
DBPass: "xxxx",
DBUser: "postgres",
}
assert.NotNil(t, conn.GetDatastoreObj())
}
func (suite *GeoserverDatastoreSuite) TestCreateDatastore() {
conn := DatastoreConnection{
Name: "datastores_test",
Port: 5432,
Type: "postgis",
DBName: "cartoview_datastore",
DBPass: "xxxx",
DBUser: "postgres",
}
created, err := suite.gsCatalog.CreateDatastore(conn, "datastores_test")
assert.True(suite.T(), created)
assert.Nil(suite.T(), err)
created, err = suite.gsCatalog.CreateDatastore(conn, "datastores_test")
assert.False(suite.T(), created)
assert.NotNil(suite.T(), err)
}
func (suite *GeoserverDatastoreSuite) TestDatastoreExists() {
exists, err := suite.gsCatalog.DatastoreExists("datastores_test", "datastores_test", true)
assert.True(suite.T(), exists)
assert.Nil(suite.T(), err)
exists, err = suite.gsCatalog.DatastoreExists("datastores_test_dummy", "datastores_test_dummy", true)
assert.False(suite.T(), exists)
assert.NotNil(suite.T(), err)
}
func (suite *GeoserverDatastoreSuite) TestDeleteDatastore() {
deleted, err := suite.gsCatalog.DeleteDatastore("datastores_test", "datastores_test", true)
assert.True(suite.T(), deleted)
assert.Nil(suite.T(), err)
deleted, err = suite.gsCatalog.DeleteDatastore("datastores_test_dummy", "datastores_test_dummy", true)
assert.False(suite.T(), deleted)
assert.NotNil(suite.T(), err)
}
func (suite *GeoserverDatastoreSuite) TestGetDatastores() {
datastores, err := suite.gsCatalog.GetDatastores("topp")
assert.NotEmpty(suite.T(), datastores)
assert.NotNil(suite.T(), datastores)
assert.Nil(suite.T(), err)
datastores, err = suite.gsCatalog.GetDatastores("topp_dummy")
assert.Nil(suite.T(), datastores)
assert.NotNil(suite.T(), err)
}
func (suite *GeoserverDatastoreSuite) TestGetDatastoreDetails() {
datastore, err := suite.gsCatalog.GetDatastoreDetails("sf", "sf")
assert.NotEmpty(suite.T(), datastore)
assert.NotNil(suite.T(), datastore)
assert.Nil(suite.T(), err)
datastore, err = suite.gsCatalog.GetDatastoreDetails("sf", "sf_dummy")
assert.Equal(suite.T(), datastore, &Datastore{})
assert.NotNil(suite.T(), err)
}
func (suite *GeoserverDatastoreSuite) TearDownSuite() {
deleted, err := suite.gsCatalog.DeleteWorkspace("datastores_test", true)
assert.True(suite.T(), deleted)
assert.Nil(suite.T(), err)
}
func TestGeoserverDatastoreSuite(t *testing.T) {
suite.Run(t, new(GeoserverDatastoreSuite))
}
func TestGeoserverImplemetDatastoreService(t *testing.T) {
gsCatalog := reflect.TypeOf(&GeoServer{})
DatastoreServiceType := reflect.TypeOf((*DatastoreService)(nil)).Elem()
check := gsCatalog.Implements(DatastoreServiceType)
assert.True(t, check)
}
func TestGeoserverImplementDatastoreService(t *testing.T) {
gsCatalog := reflect.TypeOf(&GeoServer{})
CatalogType := reflect.TypeOf((*DatastoreService)(nil)).Elem()
check := gsCatalog.Implements(CatalogType)
assert.True(t, check)
}