forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathravendb_10566_test.go
60 lines (44 loc) · 1.18 KB
/
ravendb_10566_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
package tests
import (
"sync"
"testing"
ravendb "github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
)
func ravendb10566_shouldBeAvailable(t *testing.T, driver *RavenTestDriver) {
var err error
store := driver.getDocumentStoreMust(t)
defer store.Close()
var name string
var mu sync.Mutex
afterSaveChanges := func(event *ravendb.AfterSaveChangesEventArgs) {
meta := event.GetDocumentMetadata()
nameI, ok := meta.Get("Name")
assert.True(t, ok)
mu.Lock()
defer mu.Unlock()
name = nameI.(string)
}
store.AddAfterSaveChangesListener(afterSaveChanges)
{
session := openSessionMust(t, store)
user := &User{}
user.setName("Oren")
err = session.StoreWithID(user, "users/oren")
assert.NoError(t, err)
metadata, err := session.Advanced().GetMetadataFor(user)
assert.NoError(t, err)
metadata.Put("Name", "FooBar")
err = session.SaveChanges()
assert.NoError(t, err)
session.Close()
}
assert.Equal(t, name, "FooBar")
}
func TestRavenDB10566(t *testing.T) {
driver := createTestDriver(t)
destroy := func() { destroyDriver(t, driver) }
defer recoverTest(t, destroy)
// matches Java's order
ravendb10566_shouldBeAvailable(t, driver)
}