-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathbenchmark_test.go
61 lines (48 loc) · 1.21 KB
/
benchmark_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
package gogm
import (
"context"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func TestSessionV2Impl_LoadAll(t *testing.T) {
if testing.Short() {
t.Skip()
return
}
ctx := context.Background()
req := require.New(t)
container, err := setupNeo4jContainer(ctx, neo4)
req.Nil(err)
defer container.Terminate(ctx)
config := container.GetGogmConfig()
// this is ignore because index management is part of the test
config.IndexStrategy = IGNORE_INDEX
config.CAFileLocation = filepath.Join(container.CertDir, "ca-public.crt")
gogm, err := New(config, UUIDPrimaryKeyStrategy, &a{}, &b{}, &c{}, &propTest{})
req.Nil(err)
req.NotNil(gogm)
sess, err := gogm.NewSessionV2(SessionConfig{AccessMode: AccessModeWrite})
req.Nil(err)
req.NotNil(sess)
objs := []*a{
{
PropsTest2: []string{"1"},
},
{
PropsTest2: []string{"2"},
},
}
// create 2 objects
req.Nil(sess.ManagedTransaction(ctx, func(tx TransactionV2) error {
err := tx.SaveDepth(ctx, objs[0], 0)
if err != nil {
return err
}
return tx.SaveDepth(ctx, objs[1], 0)
}))
var writeTo []*a
req.Nil(sess.LoadAllDepth(ctx, &writeTo, 0))
req.Nil(sess.Delete(ctx, writeTo[0]))
req.Nil(sess.Delete(ctx, writeTo[1]))
}