Add attachments field to one
This commit is contained in:
@@ -140,6 +140,46 @@ func TestIntegration(t *testing.T) {
|
||||
t.Fatal(some2[0].Peers())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("graph.Update(new attachment), Update(--new attachment)", func(t *testing.T) {
|
||||
err := graph.Update(ctx, "col", ones[0].Query(), operator.Set{Key: fmt.Sprintf("%s.new attachment", entity.Attachments), Value: "my new attachment"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
some1, err := graph.List(ctx, "col", ones[0].Name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("sm1 = %+v", some1[0])
|
||||
if len(some1) != 1 {
|
||||
t.Fatal(len(some1))
|
||||
}
|
||||
if v, ok := some1[0].Attachments["new attachment"]; !ok {
|
||||
t.Fatal(ok, some1[0].Attachments)
|
||||
} else if v != "my new attachment" {
|
||||
t.Fatal(v, some1[0].Attachments)
|
||||
}
|
||||
|
||||
err = graph.Update(ctx, "col", ones[0].Query(), operator.Unset(fmt.Sprintf("%s.new attachment", entity.Attachments)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
some2, err := graph.List(ctx, "col", ones[0].Name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("sm1 = %+v", some2[0])
|
||||
if len(some2) != 1 {
|
||||
t.Fatal(len(some2))
|
||||
}
|
||||
if _, ok := some2[0].Attachments["new attachment"]; ok {
|
||||
t.Fatal(ok, some2[0].Attachments)
|
||||
} else if len(some2[0].Attachments) == 0 {
|
||||
t.Fatal(len(some2[0].Attachments), some2[0].Attachments)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func randomOne() entity.One {
|
||||
@@ -151,5 +191,9 @@ func randomOne() entity.One {
|
||||
Text: "tee hee xd",
|
||||
Modified: time.Now().UnixNano(),
|
||||
Connections: map[string]entity.One{},
|
||||
Attachments: map[string]string{
|
||||
"pdf file": "/path/to.pdf",
|
||||
"png file": "/path/to.png",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user