-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
walker_test.go
41 lines (30 loc) · 910 Bytes
/
walker_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWalkImports(t *testing.T) {
dir, rm := mockGoPackageDir(t, "TestWalkImports")
defer rm()
pkgs, err := WalkImports(dir, false)
assert.NoError(t, err)
res := make(map[string]bool)
res["github.com/fake/package"] = true
res["github.com/fake/nested/inside/a/package"] = true
res["root"] = true
assert.Equal(t, res, pkgs)
negRes := make(map[string]bool)
negRes["github.com/this/does/not/exist"] = true
assert.NotEqual(t, negRes, pkgs)
}
func TestGetLicenses(t *testing.T) {
dir, rm := mockGoPackageDir(t, "TestGetLicenses")
defer rm()
pkgs, err := WalkImports(dir, false)
assert.NoError(t, err)
lics := GetLicenses(dir, pkgs, 75)
res := make(map[string]string)
res["github.com/fake/package"] = "BSD-3-Clause"
res["github.com/fake/nested/inside/a/package"] = "BSD-3-Clause"
assert.Equal(t, res, lics)
}