1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00

GO-4316: Add tests

This commit is contained in:
Sergey 2024-10-21 17:54:15 +02:00
parent 5ccd6dd09d
commit 1e1563f9ae
No known key found for this signature in database
GPG key ID: 3B6BEF79160221C6
4 changed files with 207 additions and 5 deletions

View file

@ -7,6 +7,7 @@ import (
"github.com/globalsign/mgo/bson"
"github.com/gogo/protobuf/types"
"github.com/anyproto/anytype-heart/core/block/simple"
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
"github.com/anyproto/anytype-heart/util/pbtypes"
)
@ -53,6 +54,15 @@ func (b *Block) Build() []*model.Block {
}, descendants...)
}
func (b *Block) BuildMap() map[string]simple.Block {
blocks := b.Build()
res := make(map[string]simple.Block, len(blocks))
for _, bl := range blocks {
res[bl.Id] = simple.New(bl)
}
return res
}
func mkBlock(b *model.Block, opts ...Option) *Block {
o := options{
// Init children for easier equality check in tests