Skip to content

Commit 509d7f5

Browse files
authored
[#111]: fix(edges): wrong vertices edge handling
2 parents eea947b + 179602c commit 509d7f5

File tree

15 files changed

+250
-46
lines changed

15 files changed

+250
-46
lines changed

CHANGELOG.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

pkg/graph/graph.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ func (g *Graph) AddInterfaceDep(vertex *vertex.Vertex, depID string, method Kind
9292
return nil
9393
}
9494

95-
for j := 0; j < len(depVertex.Dependencies); j++ {
96-
tmpID := depVertex.Dependencies[j].ID
97-
if tmpID == vertex.ID {
98-
return nil
99-
}
100-
}
101-
10295
vertex.NumOfDeps++
10396
vertex.Dependencies = append(vertex.Dependencies, depVertex)
10497
return nil
@@ -125,14 +118,6 @@ func (g *Graph) AddStructureDep(vertex *vertex.Vertex, depID string, method Kind
125118
return nil
126119
}
127120

128-
// append depID vertex
129-
for i := 0; i < len(depVertex.Dependencies); i++ {
130-
tmpID := depVertex.Dependencies[i].ID
131-
if tmpID == vertex.ID {
132-
return nil
133-
}
134-
}
135-
136121
vertex.NumOfDeps++
137122
vertex.Dependencies = append(vertex.Dependencies, depVertex)
138123
return nil
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package p1
2+
3+
type Foo interface {
4+
Foo() string
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package p2
2+
3+
type Bar interface {
4+
Bar() string
5+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package p1
2+
3+
import (
4+
"github.com/spiral/endure/tests/stress/CyclicDepsCollects/api/p2"
5+
)
6+
7+
type Plugin1 struct {
8+
}
9+
10+
func (p1 *Plugin1) Init() error {
11+
return nil
12+
}
13+
14+
func (p1 *Plugin1) Serve() chan error {
15+
errCh := make(chan error, 1)
16+
return errCh
17+
}
18+
19+
func (p1 *Plugin1) Stop() error {
20+
return nil
21+
}
22+
23+
func (p1 *Plugin1) Collects() []interface{} {
24+
return []interface{}{
25+
p1.GetP2,
26+
}
27+
}
28+
29+
func (p1 *Plugin1) Foo() string {
30+
return "foo"
31+
}
32+
33+
func (p1 *Plugin1) GetP2(bar p2.Bar) {
34+
_ = bar
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package p2
2+
3+
import (
4+
"github.com/spiral/endure/tests/stress/CyclicDepsCollects/api/p1"
5+
)
6+
7+
type Plugin2 struct {
8+
}
9+
10+
func (p2 *Plugin2) Init() error {
11+
return nil
12+
}
13+
14+
func (p2 *Plugin2) Serve() chan error {
15+
errCh := make(chan error, 1)
16+
return errCh
17+
}
18+
19+
func (p2 *Plugin2) Stop() error {
20+
return nil
21+
}
22+
23+
func (p2 *Plugin2) Collects() []interface{} {
24+
return []interface{}{
25+
p2.GetP1,
26+
}
27+
}
28+
29+
func (p2 *Plugin2) Bar() string {
30+
return "bar"
31+
}
32+
33+
func (p2 *Plugin2) GetP1(p1 p1.Foo) {
34+
_ = p1
35+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package p1
2+
3+
type Foo interface {
4+
Foo() string
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package p2
2+
3+
type Bar interface {
4+
Bar() string
5+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package p1
2+
3+
import (
4+
"github.com/spiral/endure/tests/stress/CyclicDepsCollects/api/p2"
5+
)
6+
7+
type Plugin1 struct {
8+
}
9+
10+
func (p1 *Plugin1) Init() error {
11+
return nil
12+
}
13+
14+
func (p1 *Plugin1) Serve() chan error {
15+
errCh := make(chan error, 1)
16+
return errCh
17+
}
18+
19+
func (p1 *Plugin1) Stop() error {
20+
return nil
21+
}
22+
23+
func (p1 *Plugin1) Collects() []interface{} {
24+
return []interface{}{
25+
p1.GetP2,
26+
}
27+
}
28+
29+
func (p1 *Plugin1) Foo() string {
30+
return "foo"
31+
}
32+
33+
func (p1 *Plugin1) GetP2(bar p2.Bar) {
34+
_ = bar
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package p2
2+
3+
import (
4+
"github.com/spiral/endure/tests/stress/CyclicDepsCollects/api/p1"
5+
)
6+
7+
type Plugin2 struct {
8+
}
9+
10+
func (p2 *Plugin2) Init() error {
11+
return nil
12+
}
13+
14+
func (p2 *Plugin2) Serve() chan error {
15+
errCh := make(chan error, 1)
16+
return errCh
17+
}
18+
19+
func (p2 *Plugin2) Stop() error {
20+
return nil
21+
}
22+
23+
func (p2 *Plugin2) Collects() []interface{} {
24+
return []interface{}{
25+
p2.GetP1,
26+
}
27+
}
28+
29+
func (p2 *Plugin2) Bar() string {
30+
return "bar"
31+
}
32+
33+
func (p2 *Plugin2) GetP1(p1 p1.Foo) {
34+
_ = p1
35+
}

0 commit comments

Comments
 (0)