diff --git a/pkg/drawio/drawio_test.go b/pkg/drawio/drawio_test.go index 19c9700ef..af8b3ae8b 100644 --- a/pkg/drawio/drawio_test.go +++ b/pkg/drawio/drawio_test.go @@ -7,6 +7,15 @@ import ( ) func TestWithParsing(t *testing.T) { + n := createNetworkSubnetGroupingOverlapping() + err := CreateDrawioConnectivityMapFile(n, "subnetGroupingOverlapping.drawio", true) + if err != nil { + fmt.Println("Error when calling CreateDrawioConnectivityMapFile():", err) + } + +} + +func TestWithParsing2(t *testing.T) { n := createNetwork() err := CreateDrawioConnectivityMapFile(n, "fake.drawio", false) if err != nil { @@ -32,6 +41,11 @@ func TestWithParsing(t *testing.T) { if err != nil { fmt.Println("Error when calling CreateDrawioConnectivityMapFile():", err) } + n = createNetworkSubnetGroupingOverlapping() + err = CreateDrawioConnectivityMapFile(n, "subnetGroupingOverlapping.drawio", true) + if err != nil { + fmt.Println("Error when calling CreateDrawioConnectivityMapFile():", err) + } n2 := NewNetworkTreeNode() NewCloudTreeNode(n2, "empty Cloud") @@ -307,7 +321,7 @@ func createGroup(zones *[][]SquareTreeNodeInterface, vpc *VpcTreeNode, i1, i2, j } } g := GroupedSubnetsSquare(vpc, gr) - g.(*GroupSubnetsSquareTreeNode).name = fmt.Sprintf("%d-%d,%d,%d", i1, i2, j1, j2) + // g.(*GroupSubnetsSquareTreeNode).name = fmt.Sprintf("%d-%d,%d,%d", i1, i2, j1, j2) return g } @@ -332,7 +346,8 @@ func createNetworkSubnetGrouping() SquareTreeNodeInterface { {0, 6, 6, 2, 3}, {0, 7, 8, 1, 2}, } - return createNetworkSubnetGroupingGeneric(groupsIndexes) + n, _ := createNetworkSubnetGroupingGeneric(groupsIndexes) + return n } func createNetworkSubnetGroupingMultiVpc() SquareTreeNodeInterface { @@ -353,10 +368,25 @@ func createNetworkSubnetGroupingMultiVpc() SquareTreeNodeInterface { {2, 16, 17, 0, 1}, {2, 17, 18, 0, 1}, } - return createNetworkSubnetGroupingGeneric(groupsIndexes) + n, _ := createNetworkSubnetGroupingGeneric(groupsIndexes) + return n } -func createNetworkSubnetGroupingGeneric(groupsIndexes []groupIndexes) SquareTreeNodeInterface { +func createNetworkSubnetGroupingOverlapping() SquareTreeNodeInterface { + groupsIndexes := []groupIndexes{ + {0, 0, 3, 0, 3}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 3, 3}, + {0, 3, 3, 0, 0}, + {0, 3, 3, 3, 3}, + } + n, groups := createNetworkSubnetGroupingGeneric(groupsIndexes) + NewConnectivityLineTreeNode(n, groups[1], groups[2], true, "gconn 0000->0033") + + return n +} + +func createNetworkSubnetGroupingGeneric(groupsIndexes []groupIndexes) (SquareTreeNodeInterface, []SquareTreeNodeInterface) { network := NewNetworkTreeNode() zones := &[][]SquareTreeNodeInterface{} cloud1 := NewCloudTreeNode(network, "IBM Cloud") @@ -390,7 +420,7 @@ func createNetworkSubnetGroupingGeneric(groupsIndexes []groupIndexes) SquareTree i1 := NewInternetTreeNode(publicNetwork, "I "+gr.Label()) NewConnectivityLineTreeNode(network, gr, i1, true, "gconn "+gr.Label()) } - return network + return network, groups } func createNetworkGrouping() SquareTreeNodeInterface {