Skip to content

Commit

Permalink
add missing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
severindellsperger committed Jul 15, 2024
1 parent 8296474 commit 23138d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/graph/network_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ func (graph *NetworkGraph) addNodesToSubgraph(newSubGraphs map[uint32]*NetworkGr
func (graph *NetworkGraph) addEdgesToSubgraph(newSubGraphs map[uint32]*NetworkGraph) {
for _, edge := range graph.edges {
for flexAlgo := range edge.GetFlexibleAlgorithms() {
_ = newSubGraphs[flexAlgo].AddEdge(edge)
if err := newSubGraphs[flexAlgo].AddEdge(edge); err != nil {
graph.log.Errorf("Error adding edge to subgraph: %s", err)
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/graph/network_graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ func TestNetworkGraph_addEdgesToSubgraph(t *testing.T) {
},
),
},
wantErr: true,
},
}

Expand All @@ -773,6 +774,9 @@ func TestNetworkGraph_addEdgesToSubgraph(t *testing.T) {
graph.edges = tt.edges
newSubGraphs := make(map[uint32]*NetworkGraph)
graph.addNodesToSubgraph(newSubGraphs)
if tt.wantErr {
graph.nodes = nil
}
graph.addEdgesToSubgraph(newSubGraphs)
assert.Equal(t, 2, len(newSubGraphs[128].edges))
assert.Equal(t, 0, len(newSubGraphs[129].edges))
Expand Down

0 comments on commit 23138d3

Please sign in to comment.