forked from poloxue/modv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph_test.go
63 lines (60 loc) · 1.42 KB
/
graph_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"bytes"
"fmt"
"io"
"testing"
)
func TestModuleGraph_Parse(t *testing.T) {
type args struct {
reader io.Reader
}
tests := []struct {
name string
args args
want []byte
}{
{
name: "full",
args: args{
bytes.NewReader([]byte(`github.com/poloxue/testmod golang.org/x/[email protected]
github.com/poloxue/testmod rsc.io/quote/[email protected]
github.com/poloxue/testmod rsc.io/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
rsc.io/quote/[email protected] rsc.io/[email protected]
rsc.io/[email protected] golang.org/x/[email protected]
rsc.io/[email protected] golang.org/x/[email protected]`))},
want: []byte(`digraph {
node [shape=box];
1 [label="github.com/poloxue/testmod"];
2 [label="golang.org/x/[email protected]"];
3 [label="rsc.io/quote/[email protected]"];
4 [label="rsc.io/[email protected]"];
5 [label="golang.org/x/[email protected]"];
6 [label="rsc.io/[email protected]"];
7 [label="golang.org/x/[email protected]"]
1 -> 2;
1 -> 3;
1 -> 4;
2 -> 5;
3 -> 6;
4 -> 7;
6 -> 7;
}`),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
moduleGraph := NewModuleGraph(tt.args.reader)
moduleGraph.Parse()
for k, v := range moduleGraph.Mods {
fmt.Println(v, k)
}
for k, v := range moduleGraph.Dependencies {
fmt.Println(k)
fmt.Println(v)
fmt.Println()
}
})
}
}