-
Notifications
You must be signed in to change notification settings - Fork 16
/
put_document_command_test.go
47 lines (36 loc) · 1.06 KB
/
put_document_command_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
package tests
import (
"testing"
"github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
)
func putDocumentCommandCanPutDocumentUsingCommand(t *testing.T, driver *RavenTestDriver) {
var err error
store := driver.getDocumentStoreMust(t)
defer store.Close()
user := &User{}
user.setName("Marcin")
user.Age = 30
node, err := entityToDocument(user)
assert.NoError(t, err)
command := ravendb.NewPutDocumentCommand("users/1", nil, node)
err = store.GetRequestExecutor("").ExecuteCommand(command, nil)
assert.NoError(t, err)
result := command.Result
assert.Equal(t, "users/1", result.ID)
assert.NotNil(t, result.ChangeVector)
{
session := openSessionMust(t, store)
var loadedUser *User
err = session.Load(&loadedUser, "users/1")
assert.NoError(t, err)
assert.Equal(t, "Marcin", *loadedUser.Name)
session.Close()
}
}
func TestPutDocumentCommand(t *testing.T) {
driver := createTestDriver(t)
destroy := func() { destroyDriver(t, driver) }
defer recoverTest(t, destroy)
putDocumentCommandCanPutDocumentUsingCommand(t, driver)
}