-
Notifications
You must be signed in to change notification settings - Fork 16
/
client_configuration_test.go
58 lines (49 loc) · 1.91 KB
/
client_configuration_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
package tests
import (
"testing"
"github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
)
func clientConfigurationCanHandleNoConfiguration(t *testing.T, driver *RavenTestDriver) {
store := driver.getDocumentStoreMust(t)
defer store.Close()
operation := ravendb.NewGetClientConfigurationOperation()
err := store.Maintenance().Send(operation)
assert.NoError(t, err)
result := operation.Command.Result
assert.Nil(t, result.Configuration)
assert.True(t, result.Etag == -2)
}
func clientConfigurationCanSaveAndReadClientConfiguration(t *testing.T, driver *RavenTestDriver) {
store := driver.getDocumentStoreMust(t)
defer store.Close()
configurationToSave := &ravendb.ClientConfiguration{
Etag: 123,
MaxNumberOfRequestsPerSession: 80,
ReadBalanceBehavior: ravendb.ReadBalanceBehaviorFastestNode,
IsDisabled: true,
}
saveOperation, err := ravendb.NewPutClientConfigurationOperation(configurationToSave)
assert.NoError(t, err)
store.Maintenance().Send(saveOperation)
operation := ravendb.NewGetClientConfigurationOperation()
err = store.Maintenance().Send(operation)
assert.NoError(t, err)
result := operation.Command.Result
println(result.Etag)
assert.True(t, result.Etag != 0)
newConfiguration := result.Configuration
assert.NotNil(t, newConfiguration)
assert.True(t, newConfiguration.Etag != configurationToSave.Etag)
assert.True(t, newConfiguration.IsDisabled)
assert.Equal(t, newConfiguration.MaxNumberOfRequestsPerSession, 80)
assert.Equal(t, newConfiguration.ReadBalanceBehavior, ravendb.ReadBalanceBehaviorFastestNode)
}
func TestClientConfiguration(t *testing.T) {
driver := createTestDriver(t)
destroy := func() { destroyDriver(t, driver) }
defer recoverTest(t, destroy)
// matches order of Java tests
clientConfigurationCanHandleNoConfiguration(t, driver)
clientConfigurationCanSaveAndReadClientConfiguration(t, driver)
}