Change connections storage from arr to map
This commit is contained in:
@@ -94,10 +94,10 @@ func fillDB(t *testing.T, g storage.Graph) []entity.One {
|
||||
for i := range ones {
|
||||
ones[i] = randomOne()
|
||||
if i > 0 {
|
||||
ones[i].Connections = []entity.One{entity.One{
|
||||
ones[i].Connections[ones[i-1].Name] = entity.One{
|
||||
Name: ones[i-1].Name,
|
||||
Relationship: ":D",
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := range ones {
|
||||
@@ -110,8 +110,12 @@ func fillDB(t *testing.T, g storage.Graph) []entity.One {
|
||||
t.Fatal(len(results))
|
||||
} else if len(results[0].Connections) != len(ones[i].Connections) {
|
||||
t.Fatal(len(results[0].Connections), len(ones[i].Connections))
|
||||
} else if len(results[0].Connections) > 0 && len(results[0].Connections[0].Name) == 0 {
|
||||
t.Fatalf("name is gone: %+v", results)
|
||||
} else if len(results[0].Connections) > 0 {
|
||||
for k, v := range results[0].Connections {
|
||||
if k == "" || v.Name == "" {
|
||||
t.Fatalf("name is gone: %q:%+v", k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ones
|
||||
@@ -125,6 +129,6 @@ func randomOne() entity.One {
|
||||
Image: "imge-" + uuid.New().String()[:5],
|
||||
Text: "text-" + uuid.New().String()[:5],
|
||||
Modified: time.Now().UnixNano(),
|
||||
Connections: []entity.One{},
|
||||
Connections: map[string]entity.One{},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user