Change connections storage from arr to map

This commit is contained in:
Bel LaPointe
2020-07-22 22:12:40 -06:00
parent 82975a7101
commit 1a6973b02c
4 changed files with 61 additions and 59 deletions

View File

@@ -31,7 +31,7 @@ func TestOneMarshalBSON(t *testing.T) {
one: (One{Name: "hello", Type: "world", Modified: 1}),
},
"w/ connections": {
one: (One{Name: "hello", Type: "world", Modified: 1, Connections: []One{One{Name: "hi", Relationship: "mom"}}}),
one: (One{Name: "hello", Type: "world", Modified: 1, Connections: map[string]One{"hi": One{Name: "hi", Relationship: "mom"}}}),
},
}
@@ -56,8 +56,10 @@ func TestOneMarshalBSON(t *testing.T) {
}
c.one.Modified = 0
one.Modified = 0
for i := range one.Connections {
one.Connections[i].Modified = 0
for k := range one.Connections {
temp := one.Connections[k]
temp.Modified = 0
one.Connections[k] = temp
}
if fmt.Sprint(c.one) != fmt.Sprint(one) {
t.Error(c.one, one)