-
Notifications
You must be signed in to change notification settings - Fork 16
/
ravendb_12132_test.go
68 lines (52 loc) · 1.86 KB
/
ravendb_12132_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
package tests
import (
"github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
"reflect"
"testing"
)
func canCreateClusterTransactionRequest1(t *testing.T, driver *RavenTestDriver) {
store := driver.getDocumentStoreMust(t)
{
session := openSessionMustWithOptions(t, store, &ravendb.SessionOptions{
Database: "",
RequestExecutor: nil,
TransactionMode: ravendb.TransactionMode_ClusterWide,
DisableAtomicDocumentWritesInClusterWideTransaction: nil,
})
var err error
user := &Document{ID: "this/is/my/id", Name: "Grisha"}
assert.NotNil(t, session.Advanced().ClusterTransaction())
_, err = session.Advanced().ClusterTransaction().CreateCompareExchangeValue("usernames/ayende", user)
assert.NoError(t, err)
err = session.SaveChanges()
assert.NoError(t, err)
var result *ravendb.CompareExchangeValue
result, err = session.Advanced().ClusterTransaction().GetCompareExchangeValue(reflect.TypeOf(&Document{}), "usernames/ayende")
userFromCluster, cast := result.GetValue().(*Document)
assert.True(t, cast)
assert.NoError(t, err)
assert.Equal(t, user.Name, userFromCluster.Name)
assert.Equal(t, user.ID, userFromCluster.ID)
session.Close()
}
{
operation, err := ravendb.NewGetCompareExchangeValueOperation(reflect.TypeOf(&Document{}), "usernames/ayende")
assert.NoError(t, err)
err = store.Operations().Send(operation, nil)
assert.NoError(t, err)
result := operation.Command.Result
assert.NotNil(t, result)
docFromServer := result.Value.(*Document)
assert.Equal(t, "Grisha", docFromServer.Name)
assert.Equal(t, "this/is/my/id", docFromServer.ID)
}
store.Close()
}
func TestRavenDB12132(t *testing.T) {
driver := createTestDriver(t)
destroy := func() { destroyDriver(t, driver) }
defer recoverTest(t, destroy)
// matches the order of Java tests
canCreateClusterTransactionRequest1(t, driver)
}