fix(test): 1. solve testdata error 2. update shell to run test

pull/37/head
hxzhao527 2018-12-29 14:49:49 +08:00 committed by kun
parent 4cc5c7e7b7
commit b0865d643c
3 changed files with 11 additions and 5 deletions

View File

@ -1,10 +1,9 @@
#!/bin/bash
go env
export GO111MODULE=on
go generate
go mod tidy
go test -v `(go list ./... | grep "pkg/proxy")`
# build
go build -o bin/goproxy

View File

@ -10,6 +10,7 @@ import (
"path/filepath"
"strings"
"github.com/goproxyio/goproxy/pkg/cfg"
"github.com/goproxyio/goproxy/pkg/modfetch"
"github.com/goproxyio/goproxy/pkg/modfetch/codehost"
"github.com/goproxyio/goproxy/pkg/module"
@ -23,9 +24,15 @@ type modInfo struct {
suf string
}
func NewProxy(cache string) http.Handler {
modfetch.PkgMod = filepath.Join(cache, "pkg", "mod")
func setupEnv(basedir string) {
modfetch.QuietLookup = true // just to hide modfetch/cache.go#127
modfetch.PkgMod = filepath.Join(basedir, "pkg", "mod")
codehost.WorkRoot = filepath.Join(modfetch.PkgMod, "cache", "vcs")
cfg.CmdName = "mod download" // just to hide modfetch/fetch.go#L87
}
func NewProxy(cache string) http.Handler {
setupEnv(cache)
cacheDir = filepath.Join(modfetch.PkgMod, "cache", "download")
innerHandle = http.FileServer(http.Dir(cacheDir))

View File

@ -76,7 +76,7 @@ var _modInfoTests = []struct {
path: "github.com/PuerkitoBio/goquery",
version: "v0.0.0-20181014175806-2af3d16e2bb8",
time: time.Date(2018, 10, 14, 17, 58, 6, 0, time.UTC),
gomod: `module github.com/PuerkitoBio/goquery\n`,
gomod: "module github.com/PuerkitoBio/goquery\n",
zip: []string{
".gitattributes",
".gitignore",