MCPcopy Create free account
hub / github.com/RTradeLtd/Lens / TestEngine_parallel

Function TestEngine_parallel

engine/engine_parallel_test.go:15–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestEngine_parallel(t *testing.T) {
16 var l = zaptest.NewLogger(t).Sugar()
17 e, err := New(l, Opts{
18 StorePath: filepath.Join("tmp", t.Name()),
19 Queue: queue.Options{
20 Rate: 500 * time.Millisecond,
21 BatchSize: 1,
22 }})
23 if err != nil {
24 t.Error("failed to create engine: " + err.Error())
25 }
26 go e.Run()
27
28 // each case must be able to successfully index the given args.object and content
29 type args struct {
30 object *models.ObjectV2
31 content string
32 }
33 tests := []struct {
34 args args
35 }{
36 {args{&models.ObjectV2{
37 Hash: "abcde",
38 MD: models.MetaDataV2{},
39 }, "quick brown fox"}},
40 {args{&models.ObjectV2{
41 Hash: "asdf",
42 MD: models.MetaDataV2{},
43 }, "slow white fox"}},
44 {args{&models.ObjectV2{
45 Hash: "qwewqr",
46 MD: models.MetaDataV2{},
47 }, "hungry grey fox"}},
48 {args{&models.ObjectV2{
49 Hash: "oiuysa",
50 MD: models.MetaDataV2{
51 DisplayName: "launch pad",
52 Category: "clubs",
53 Tags: []string{"ubc"},
54 },
55 }, "ubc launch pad"}},
56 {args{&models.ObjectV2{
57 Hash: "oishii",
58 MD: models.MetaDataV2{
59 DisplayName: "rtrade",
60 Category: "startup",
61 Tags: []string{"ipfs", "decentralized"},
62 },
63 }, "rtrade technologies"}},
64 }
65 t.Run("tests", func(t *testing.T) {
66 for _, tt := range tests {
67 var tcase = tt // copy case
68 t.Run("object "+tcase.args.object.Hash, func(t *testing.T) {
69 t.Parallel()
70
71 // request index
72 if err := e.Index(Document{tcase.args.object, tcase.args.content, true}); err != nil {

Callers

nothing calls this directly

Calls 7

NewFunction · 0.70
IndexMethod · 0.65
IsIndexedMethod · 0.65
SearchMethod · 0.65
RemoveMethod · 0.65
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected