diff --git a/d2graph/serde.go b/d2graph/serde.go index 76e83ae2c..638e2bc82 100644 --- a/d2graph/serde.go +++ b/d2graph/serde.go @@ -2,7 +2,6 @@ package d2graph import ( "encoding/json" - "strings" "oss.terrastruct.com/util-go/go2" ) @@ -49,7 +48,7 @@ func DeserializeGraph(bytes []byte, g *Graph) error { for _, id := range so["ChildrenArray"].([]interface{}) { o := idToObj[id.(string)] childrenArray = append(childrenArray, o) - children[strings.ToLower(id.(string))] = o + children[o.IDVal] = o o.Parent = idToObj[so["AbsID"].(string)] } diff --git a/d2graph/serde_test.go b/d2graph/serde_test.go index 070400f20..e882c8fba 100644 --- a/d2graph/serde_test.go +++ b/d2graph/serde_test.go @@ -31,6 +31,12 @@ func TestSerialization(t *testing.T) { g.Root.ChildrenArray[0].Parent, ) + a := g.Root.ChildrenArray[0] + aa := a.ChildrenArray[0] + assert.Contains(t, a.Children, "a") + assert.Contains(t, aa.Children, "b") + assert.Contains(t, aa.Children, "c") + assert.Equal(t, 1, len(g.Edges)) assert.Equal(t, "b", g.Edges[0].Src.ID) assert.Equal(t, "c", g.Edges[0].Dst.ID)