Storage to uuids

This commit is contained in:
breel
2020-08-07 16:15:52 -06:00
parent 953d2d1365
commit 304956da74
17 changed files with 862 additions and 186 deletions

View File

@@ -29,7 +29,7 @@ func TestIntegration(t *testing.T) {
randomOne(),
randomOne(),
}
ones[0].Connections = map[string]entity.One{ones[2].Name: entity.One{Name: ones[2].Name, Relationship: ":("}}
ones[0].Connections = map[string]entity.Connection{ones[2].Name: entity.Connection{Relationship: ":("}}
ones[1].Name = ones[0].Name[1 : len(ones[0].Name)-1]
cleanFill := func() {
clean()
@@ -62,6 +62,30 @@ func TestIntegration(t *testing.T) {
}
})
t.Run("graph.Get 404", func(t *testing.T) {
cleanFill()
_, err := graph.Get(ctx, "col", "fake_here")
if err == nil {
t.Fatal(err)
}
})
t.Run("graph.Get", func(t *testing.T) {
cleanFill()
all, err := graph.List(ctx, "col")
if err != nil {
t.Fatal(err)
}
want := all[0]
got, err := graph.Get(ctx, "col", want.ID)
if err != nil {
t.Fatal(err)
}
if got.ID != want.ID {
t.Fatal(got)
}
})
t.Run("graph.ListCaseInsensitive", func(t *testing.T) {
cleanFill()
all, err := graph.ListCaseInsensitive(ctx, "col")
@@ -201,9 +225,9 @@ func TestIntegration(t *testing.T) {
t.Run("graph.Update(foo, +=2); graph.Update(foo, -=1)", func(t *testing.T) {
cleanFill()
err := graph.Update(ctx, "col", ones[0].Query(), operator.Set{entity.Connections, map[string]entity.One{
"hello": entity.One{Name: "hello", Relationship: ":("},
"world": entity.One{Name: "world", Relationship: ":("},
err := graph.Update(ctx, "col", ones[0].Query(), operator.Set{entity.Connections, map[string]entity.Connection{
"hello": entity.Connection{Relationship: ":("},
"world": entity.Connection{Relationship: ":("},
}})
if err != nil {
t.Fatal(err)
@@ -240,7 +264,7 @@ func TestIntegration(t *testing.T) {
t.Run("graph.Update(new attachment), Update(--new attachment)", func(t *testing.T) {
cleanFill()
err := graph.Update(ctx, "col", ones[0].Query(), operator.Set{Key: fmt.Sprintf("%s.new attachment", entity.Attachments), Value: "my new attachment"})
err := graph.Update(ctx, "col", ones[0].Query(), operator.Set{Key: fmt.Sprintf("%s.new attachment", entity.Attachments), Value: entity.Attachment{Location: "my new attachment"}})
if err != nil {
t.Fatal(err)
}
@@ -255,8 +279,8 @@ func TestIntegration(t *testing.T) {
}
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)
} else if v.Location != "my new attachment" {
t.Fatalf("when listing from DB, did not find updated attachment: got %+v from %+v", v, some1[0].Attachments)
}
err = graph.Update(ctx, "col", ones[0].Query(), operator.Unset(fmt.Sprintf("%s.new attachment", entity.Attachments)))
@@ -372,10 +396,10 @@ func randomOne() entity.One {
Title: "Biggus",
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",
Connections: map[string]entity.Connection{},
Attachments: map[string]entity.Attachment{
"pdf file": entity.Attachment{Location: "/path/to.pdf"},
"png file": entity.Attachment{Location: "/path/to.png"},
},
}
}