-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackages_test.go
76 lines (61 loc) · 1.28 KB
/
packages_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
64
65
66
67
68
69
70
71
72
73
74
75
76
package kama
import (
"testing"
"go.akshayshah.org/attest"
)
func TestStdlibPackages(t *testing.T) {
t.Parallel()
tt := []struct {
tName string
importPath string
}{
{
tName: "stdlib errors pkg",
importPath: "errors",
},
{
tName: "stdlib archive/tar pkg",
importPath: "archive/tar",
},
}
for _, v := range tt {
v := v
t.Run(v.tName, func(t *testing.T) {
t.Parallel()
p, err := newPak(v.importPath)
attest.Ok(t, err)
path := getDataPath(t, "packages_test.go", v.tName)
dealWithTestData(t, path, p.String())
})
}
}
func TestThirdPartyPackages(t *testing.T) {
t.Parallel()
tt := []struct {
tName string
importPath string
}{
{
tName: "third party github.com/pkg/errors",
importPath: "github.com/pkg/errors",
},
}
for _, v := range tt {
v := v
t.Run(v.tName, func(t *testing.T) {
t.Parallel()
p, err := newPak(v.importPath)
attest.Ok(t, err)
path := getDataPath(t, "packages_test.go", v.tName)
dealWithTestData(t, path, p.String())
})
}
}
func TestError(t *testing.T) {
t.Parallel()
_, err := newPak("github.com/pkg/NoSuchModule")
if err == nil {
t.Errorf("got no error, yet expected an error")
}
attest.Subsequence(t, err.Error(), "no required module provides package")
}