Fix failing go1.16 test

Fixes #132
This commit is contained in:
Eyal Posener 2021-01-30 11:13:29 +02:00
parent 246bd25c47
commit 5d9f7f10f0
4 changed files with 44 additions and 39 deletions

1
go.mod
View File

@ -1,6 +1,7 @@
module github.com/posener/complete/v2 module github.com/posener/complete/v2
require ( require (
bou.ke/monkey v1.0.2
github.com/hashicorp/go-multierror v1.0.0 github.com/hashicorp/go-multierror v1.0.0
github.com/posener/autogen v0.0.2 github.com/posener/autogen v0.0.2
github.com/posener/script v1.1.5 github.com/posener/script v1.1.5

2
go.sum
View File

@ -1,3 +1,5 @@
bou.ke/monkey v1.0.2 h1:kWcnsrCNUatbxncxR/ThdYqbytgOIArtYWqcQLQzKLI=
bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=

View File

@ -536,14 +536,14 @@ func main() {
modHelp := &complete.Command{ modHelp := &complete.Command{
Sub: map[string]*complete.Command{ Sub: map[string]*complete.Command{
"download": &complete.Command{}, "download": {},
"edit": &complete.Command{}, "edit": {},
"graph": &complete.Command{}, "graph": {},
"init": &complete.Command{}, "init": {},
"tidy": &complete.Command{}, "tidy": {},
"vendor": &complete.Command{}, "vendor": {},
"verify": &complete.Command{}, "verify": {},
"why": &complete.Command{}, "why": {},
}, },
} }
@ -563,38 +563,38 @@ func main() {
help := &complete.Command{ help := &complete.Command{
Sub: map[string]*complete.Command{ Sub: map[string]*complete.Command{
"bug": &complete.Command{}, "bug": {},
"build": &complete.Command{}, "build": {},
"clean": &complete.Command{}, "clean": {},
"doc": &complete.Command{}, "doc": {},
"env": &complete.Command{}, "env": {},
"fix": &complete.Command{}, "fix": {},
"fmt": &complete.Command{}, "fmt": {},
"generate": &complete.Command{}, "generate": {},
"get": &complete.Command{}, "get": {},
"install": &complete.Command{}, "install": {},
"list": &complete.Command{}, "list": {},
"mod": modHelp, "mod": modHelp,
"run": &complete.Command{}, "run": {},
"test": &complete.Command{}, "test": {},
"tool": &complete.Command{}, "tool": {},
"version": &complete.Command{}, "version": {},
"vet": &complete.Command{}, "vet": {},
"buildmode": &complete.Command{}, "buildmode": {},
"c": &complete.Command{}, "c": {},
"cache": &complete.Command{}, "cache": {},
"environment": &complete.Command{}, "environment": {},
"filetype": &complete.Command{}, "filetype": {},
"go.mod": &complete.Command{}, "go.mod": {},
"gopath": &complete.Command{}, "gopath": {},
"gopath-get": &complete.Command{}, "gopath-get": {},
"goproxy": &complete.Command{}, "goproxy": {},
"importpath": &complete.Command{}, "importpath": {},
"modules": &complete.Command{}, "modules": {},
"module-get": &complete.Command{}, "module-get": {},
"packages": &complete.Command{}, "packages": {},
"testflag": &complete.Command{}, "testflag": {},
"testfunc": &complete.Command{}, "testfunc": {},
}, },
} }

View File

@ -5,6 +5,7 @@ import (
"sort" "sort"
"testing" "testing"
"bou.ke/monkey"
"github.com/posener/complete/v2" "github.com/posener/complete/v2"
) )
@ -42,6 +43,7 @@ func TestPredictions(t *testing.T) {
func BenchmarkFake(b *testing.B) {} func BenchmarkFake(b *testing.B) {}
func Example() { func Example() {
monkey.Patch(os.Exit, func(int) {})
os.Setenv("COMP_LINE", "go ru") os.Setenv("COMP_LINE", "go ru")
os.Setenv("COMP_POINT", "5") os.Setenv("COMP_POINT", "5")
main() main()