@@ -4,19 +4,31 @@ import (
44 "encoding/json"
55 "github.com/murphysecurity/murphysec/utils/must"
66 "github.com/stretchr/testify/assert"
7+ "io"
78 "testing"
89)
910
10- func TestParseLockfile (t * testing.T ) {
11- for i , s := range testDataList {
12- lockfile , e := ParseLockfile ([]byte (s ))
13- assert .NoError (t , e , i )
14- assert .NotNil (t , lockfile , i )
11+ func TestLockfile (t * testing.T ) {
12+ files , _ := testFiles .ReadDir ("testdata" )
13+ assert .NotEmpty (t , files )
14+ for _ , s := range files {
15+ t .Run (s .Name (), func (t * testing.T ) {
16+ f , e := testFiles .Open ("testdata/" + s .Name ())
17+ assert .NoError (t , e )
18+ defer func () { assert .NoError (t , f .Close ()) }()
19+ data , e := io .ReadAll (f )
20+ assert .NoError (t , e )
21+ lockfile , e := ParseLockfile (data )
22+ assert .NoError (t , e )
23+ assert .NotNil (t , lockfile )
24+
25+ })
1526 }
1627}
1728
1829func TestBuildDepTree (t * testing.T ) {
19- l , _ := ParseLockfile ([]byte (testDataList [4 ]))
30+
31+ l , _ := ParseLockfile ([]byte (testData5 ))
2032 tree := BuildDepTree (l , nil , "" )
2133 assert .NotNil (t , tree )
2234 t .Log (string (must .A (json .MarshalIndent (tree , "| " , " " ))))
0 commit comments