-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain_test.go
More file actions
45 lines (38 loc) · 944 Bytes
/
main_test.go
File metadata and controls
45 lines (38 loc) · 944 Bytes
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
package main
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/rogpeppe/go-internal/testscript"
"github.com/icholy/gomajor/internal/modproxy/testmodproxy"
)
func TestMain(m *testing.M) {
testscript.Main(m, map[string]func(){
"gomajor": main,
})
}
func TestListCommand(t *testing.T) {
testscript.Run(t, testscript.Params{
Dir: "testdata/testscript/list",
Setup: func(env *testscript.Env) error {
proxyfs, err := testmodproxy.LoadFS("testdata/modules")
if err != nil {
return err
}
server := httptest.NewServer(http.FileServer(http.FS(proxyfs)))
env.Vars = append(env.Vars, "GOPROXY="+server.URL)
env.Defer(func() { server.Close() })
return nil
},
})
}
func TestHelpCommand(t *testing.T) {
testscript.Run(t, testscript.Params{
Dir: "testdata/testscript/help",
})
}
func TestPathCommand(t *testing.T) {
testscript.Run(t, testscript.Params{
Dir: "testdata/testscript/path",
})
}