Skip to content

Commit

Permalink
fix(#53): direct impact did not contain itself
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfzc committed Jul 27, 2023
1 parent 842d850 commit 4d05b6d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion graph/file/api_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
func (fg *Graph) GetById(id string) *Vertex {
v, err := fg.G.Vertex(id)
if err != nil {

logrus.Warnf("no vertex: %v", id)
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions graph/file/api_query_ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ func TestQuery(t *testing.T) {
assert.NotEmpty(t, shouldNotEmpty)
log.Infof("outv: %d", len(shouldNotEmpty))
})

t.Run("Entries", func(t *testing.T) {
entries := fg.EntryIds(fg.GetById("graph/function/api_query_test.go"))
// test case usually is an entry point
assert.Len(t, entries, 1)
})
}
3 changes: 3 additions & 0 deletions graph/function/api_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func (fg *Graph) GlobalStat(points []*Vertex) *object.StatGlobal {
eachId := sg.UnitMapping[eachReference]
directImpactMap[eachId] = struct{}{}
}
// and itself
itselfId := sg.UnitMapping[each.Self.Id()]
directImpactMap[itselfId] = struct{}{}
}
directImpactList := make([]int, 0, len(directImpactMap))
for each := range directImpactMap {
Expand Down

0 comments on commit 4d05b6d

Please sign in to comment.