make map driver type for faster tests
This commit is contained in:
38
storage/driver/map_test.go
Normal file
38
storage/driver/map_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package driver
|
||||
|
||||
import (
|
||||
"local/dndex/storage/entity"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
func tempMap(t *testing.T) *Map {
|
||||
mp := NewMap()
|
||||
mp.db[testNS] = map[string][]byte{}
|
||||
for i := 0; i < testN; i++ {
|
||||
p := entity.One{
|
||||
Name: "name-" + uuid.New().String()[:5],
|
||||
Type: "type-" + uuid.New().String()[:5],
|
||||
Relationship: "rshp-" + uuid.New().String()[:5],
|
||||
Title: "titl-" + uuid.New().String()[:5],
|
||||
}
|
||||
o := entity.One{
|
||||
Name: "name-" + uuid.New().String()[:5],
|
||||
Type: "type-" + uuid.New().String()[:5],
|
||||
Title: "titl-" + uuid.New().String()[:5],
|
||||
Text: "text-" + uuid.New().String()[:5],
|
||||
Modified: time.Now().UnixNano(),
|
||||
Connections: map[string]entity.One{p.Name: p},
|
||||
Attachments: map[string]string{"filename": "/path/to/file"},
|
||||
}
|
||||
b, err := bson.Marshal(o)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mp.db[testNS][o.Name] = b
|
||||
}
|
||||
return mp
|
||||
}
|
||||
Reference in New Issue
Block a user