-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsettings_test.go
46 lines (36 loc) · 1.4 KB
/
settings_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
package geoserver
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestGetGlobalSettings(t *testing.T) {
gsCatalog := GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
settings, err := gsCatalog.GetGlobalSettings()
assert.NotNil(t, settings)
assert.Nil(t, err)
}
func TestUpdateGlobalSetting(t *testing.T) {
// Get the initial settings of this geoserver
gsCatalog := GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
initialSettings, err := gsCatalog.GetGlobalSettings()
assert.NotNil(t, initialSettings)
assert.Nil(t, err)
updateSettings := initialSettings
updateSettings.Global.Settings.NumDecimals = 200
// Update the settings
gsCatalog = GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
modified, err := gsCatalog.UpdateGlobalSetting(updateSettings)
assert.True(t, modified)
assert.Nil(t, err)
// Check if the update succeeded
gsCatalog = GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
updatedSettings, err := gsCatalog.GetGlobalSettings()
assert.NotNil(t, updatedSettings)
assert.Nil(t, err)
assert.Equal(t, 200, updatedSettings.Global.Settings.NumDecimals)
// Reset settings to initial ones
gsCatalog = GetCatalog("http://localhost:8080/geoserver/", "admin", "geoserver")
updatedModified, err := gsCatalog.UpdateGlobalSetting(initialSettings)
assert.True(t, updatedModified)
assert.Nil(t, err)
}