-
Notifications
You must be signed in to change notification settings - Fork 16
/
compact_test.go
48 lines (39 loc) · 1.33 KB
/
compact_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
package tests
import (
"strings"
"testing"
"github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
)
func compactTestCanCompactDatabase(t *testing.T, driver *RavenTestDriver) {
var err error
store := driver.getDocumentStoreMust(t)
defer store.Close()
{
newSession := openSessionMust(t, store)
user1 := &User{}
user1.setLastName("user1")
err = newSession.StoreWithID(user1, "users/1")
assert.NoError(t, err)
err = newSession.SaveChanges()
assert.NoError(t, err)
newSession.Close()
}
compactSettings := &ravendb.CompactSettings{}
compactSettings.DatabaseName = store.GetDatabase()
compactSettings.Documents = true
compactOp := ravendb.NewCompactDatabaseOperation(compactSettings)
operation, err := store.Maintenance().Server().SendAsync(compactOp)
assert.NoError(t, err)
// we can't compact in memory database but here we just test is request was send successfully
err = operation.WaitForCompletion()
msg := err.Error()
assert.True(t, strings.Contains(msg, "Unable to cast object of type 'PureMemoryStorageEnvironmentOptions' to type 'DirectoryStorageEnvironmentOptions'"))
}
func TestCompact(t *testing.T) {
driver := createTestDriver(t)
destroy := func() { destroyDriver(t, driver) }
defer recoverTest(t, destroy)
// follows execution order of java tests
compactTestCanCompactDatabase(t, driver)
}