-
Notifications
You must be signed in to change notification settings - Fork 16
/
get_statistics_command_test.go
62 lines (53 loc) · 1.97 KB
/
get_statistics_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package tests
import (
"testing"
"github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
)
func getStatisticsCommandTestCanGetStats(t *testing.T, driver *RavenTestDriver) {
var err error
store := driver.getDocumentStoreMust(t)
defer store.Close()
executor := store.GetRequestExecutor("")
sampleData := ravendb.NewCreateSampleDataOperation()
err = store.Maintenance().Send(sampleData)
assert.NoError(t, err)
err = driver.waitForIndexing(store, store.GetDatabase(), 0)
assert.NoError(t, err)
command := ravendb.NewGetStatisticsCommand("")
assert.NoError(t, err)
err = executor.ExecuteCommand(command, nil)
assert.NoError(t, err)
stats := command.Result
assert.NotNil(t, stats)
assert.True(t, stats.LastDocEtag > 0)
assert.Equal(t, stats.CountOfIndexes, 7)
assert.Equal(t, stats.CountOfDocuments, int64(1059))
assert.True(t, stats.CountOfRevisionDocuments > 0)
assert.Equal(t, stats.CountOfDocumentsConflicts, int64(0))
assert.Equal(t, stats.CountOfConflicts, int64(0))
assert.Equal(t, stats.CountOfUniqueAttachments, int64(17))
assert.NotEqual(t, stats.DatabaseChangeVector, "")
assert.NotEqual(t, stats.DatabaseID, "")
assert.NotNil(t, stats.Pager)
assert.NotNil(t, stats.GetLastIndexingTime())
assert.NotNil(t, stats.Indexes)
assert.NotEqual(t, stats.SizeOnDisk.HumaneSize, "")
assert.NotEqual(t, stats.SizeOnDisk.SizeInBytes, 0)
indexes := stats.Indexes
for _, indexInformation := range indexes {
assert.NotEqual(t, indexInformation.Name, "")
assert.False(t, indexInformation.IsStale)
assert.NotNil(t, indexInformation.State)
assert.NotEqual(t, indexInformation.LockMode, "")
assert.NotEqual(t, indexInformation.Priority, "")
assert.NotEqual(t, indexInformation.Type, "")
assert.NotNil(t, indexInformation.GetLastIndexingTime())
}
}
func TestGetStatisticsCommand(t *testing.T) {
driver := createTestDriver(t)
destroy := func() { destroyDriver(t, driver) }
defer recoverTest(t, destroy)
getStatisticsCommandTestCanGetStats(t, driver)
}