dndex/storage/driver/map_test.go

39 lines
978 B
Go

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
}