-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhere_test.go
48 lines (38 loc) · 857 Bytes
/
here_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
package here
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func Test_nonGoDirRx(t *testing.T) {
r := require.New(t)
r.False(nonGoDirRx.MatchString(""))
r.False(nonGoDirRx.MatchString("hello"))
table := []string{
"go: cannot find main module; see 'go help modules'",
"go help modules",
"go: ",
"build .:",
"no Go files",
"can't load package",
}
for _, tt := range table {
t.Run(tt, func(st *testing.T) {
r := require.New(st)
b := nonGoDirRx.MatchString(tt)
r.True(b)
})
}
}
func sanityCheck(t *testing.T, info Info) {
t.Helper()
r := require.New(t)
root, err := os.Getwd()
r.NoError(err)
r.NotZero(info)
r.Equal(root, info.Dir)
r.Equal(filepath.Join(root, "go.mod"), info.Module.GoMod)
r.Equal("github.com/gobuffalo/here", info.ImportPath)
r.Equal("here", info.Name)
}