From 0ccc5936216114203cee95916bc6ce45e2f0e7d3 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Mon, 2 Oct 2023 08:37:40 -0400 Subject: [PATCH] ensure unresolved go-proxy version does not check online (#9) Signed-off-by: Alex Goodman --- tool/goproxy/version_resolver.go | 2 +- tool/goproxy/version_resolver_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tool/goproxy/version_resolver.go b/tool/goproxy/version_resolver.go index 5170887..6b1e825 100644 --- a/tool/goproxy/version_resolver.go +++ b/tool/goproxy/version_resolver.go @@ -38,7 +38,7 @@ func (v VersionResolver) ResolveVersion(want, _ string) (string, error) { return want, nil } - if want == latest { + if want == latest && !v.config.AllowUnresolvedVersion { return v.findLatestVersion("") } diff --git a/tool/goproxy/version_resolver_test.go b/tool/goproxy/version_resolver_test.go index d1c4f07..02812fd 100644 --- a/tool/goproxy/version_resolver_test.go +++ b/tool/goproxy/version_resolver_test.go @@ -1,6 +1,7 @@ package goproxy import ( + "fmt" "testing" "github.com/stretchr/testify/assert" @@ -64,7 +65,7 @@ func TestVersionResolver_ResolveVersion(t *testing.T) { version: "latest", want: "latest", // this is a pass through to go-install, which supports this as input availableVersionsFetcher: func(url string) ([]string, error) { - return []string{""}, nil + return nil, fmt.Errorf("should never be called") }, }, }