From a22d4b339d827f6f9a0ecc18e57f60dea27e92e5 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Sun, 19 Jul 2020 21:29:10 +0800 Subject: [PATCH] refactor: extract map node --- pkg/application/arch/tequila/incl_viz.go | 8 +++++++- pkg/application/arch/tequila/incl_viz_test.go | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pkg/application/arch/tequila/incl_viz.go b/pkg/application/arch/tequila/incl_viz.go index 1c5d6f7..2acb6ea 100644 --- a/pkg/application/arch/tequila/incl_viz.go +++ b/pkg/application/arch/tequila/incl_viz.go @@ -145,7 +145,7 @@ type GraphNode struct { children []*GraphNode } -func (fullGraph *FullGraph) ToMapDot(split string, include func(key string) bool) *GraphNode { +func (fullGraph *FullGraph) BuildMapTree(split string, include func(key string) bool) *GraphNode { graph := gographviz.NewGraph() _ = graph.SetName("G") @@ -160,6 +160,12 @@ func (fullGraph *FullGraph) ToMapDot(split string, include func(key string) bool return graphNode } +func (f *FullGraph) ToMapDot(node *GraphNode) { + +} + + + func buildNode(arr []string, node *GraphNode) *GraphNode { if node.text == arr[0] { diff --git a/pkg/application/arch/tequila/incl_viz_test.go b/pkg/application/arch/tequila/incl_viz_test.go index 5efe0fc..b58054d 100644 --- a/pkg/application/arch/tequila/incl_viz_test.go +++ b/pkg/application/arch/tequila/incl_viz_test.go @@ -5,8 +5,7 @@ import ( "testing" ) -func Test_VisualDemo(t *testing.T) { - g := NewGomegaWithT(t) +func createBasicMap() (*GraphNode, *FullGraph) { fullGraph := &FullGraph{ NodeList: make(map[string]string), RelationList: make(map[string]*Relation), @@ -28,7 +27,13 @@ func Test_VisualDemo(t *testing.T) { return true } - node := fullGraph.ToMapDot(".", nodeFilter) + node := fullGraph.BuildMapTree(".", nodeFilter) + return node, fullGraph +} + +func Test_BuildGraphNode(t *testing.T) { + g := NewGomegaWithT(t) + node, _ := createBasicMap() g.Expect(node.text).To(Equal("com")) children := node.children @@ -36,3 +41,11 @@ func Test_VisualDemo(t *testing.T) { g.Expect(children[0].text).To(Equal("phodal")) g.Expect(children[1].text).To(Equal("spring")) } + +func Test_BuildNodeDot(t *testing.T) { + g := NewGomegaWithT(t) + node, graph := createBasicMap() + graph.ToMapDot(node) + + g.Expect(true).To(Equal(true)) +} -- GitLab