Add attachments field to one

This commit is contained in:
Bel LaPointe
2020-07-24 11:21:16 -06:00
parent ed3006d359
commit 99fb3bb1c3
5 changed files with 72 additions and 19 deletions

View File

@@ -129,6 +129,9 @@ func TestBoltDBFind(t *testing.T) {
if o.Modified == 0 {
t.Error(o.Modified)
}
if len(o.Attachments) == 0 {
t.Error(o.Attachments)
}
if len(o.Connections) == 0 {
t.Error(o.Connections)
}
@@ -367,6 +370,12 @@ func fillBoltDB(t *testing.T, bdb *BoltDB) {
return err
}
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],
@@ -374,15 +383,9 @@ func fillBoltDB(t *testing.T, bdb *BoltDB) {
Image: "imge-" + uuid.New().String()[:5],
Text: "text-" + uuid.New().String()[:5],
Modified: time.Now().UnixNano(),
Connections: map[string]entity.One{},
Connections: map[string]entity.One{p.Name: p},
Attachments: map[string]string{"filename": "/path/to/file"},
}
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.Connections[p.Name] = p
b, err := bson.Marshal(o)
if err != nil {
return err