Documentation ¶
Overview ¶
Package proxytest supports testing with the proxy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
CommitTime is the time returned by all calls to the .info endpoint.
Functions ¶
func NewClientForServer ¶
NewClientForServer starts serving proxyMux locally. It returns a client to the server and a function to shut down the server.
func SetupTestClient ¶
SetupTestClient creates a fake module proxy for testing using the given test version information.
It returns a function for tearing down the proxy after the test is completed and a Client for interacting with the test proxy.
Types ¶
type Module ¶
type Module struct { ModulePath string Version string Files map[string]string NotCached bool // if true, behaves like it's uncached // contains filtered or unexported fields }
Module represents a module version used by the proxy server.
func FindModule ¶
FindModule returns the module in mods with the given path and version, or nil if there isn't one. An empty version argument matches any version.
func LoadTestModules ¶
LoadTestModules reads the modules in the given directory. Each file in that directory with a .txtar extension should be named "path@version" and should be in txtar format (golang.org/x/tools/txtar). The path part of the filename will be preceded by "example.com/" and colons will be replaced by slashes to form a full module path. The file contents are used verbatim except that some variables beginning with "$" are substituted with predefined strings.
LoadTestModules panics if there is an error reading any of the files.
func (*Module) AddFile ¶
AddFile returns a copy of m with an additional file. It panics if the filename is already present.
func (*Module) ChangePath ¶
ChangePath returns a copy of m with a different module path.
func (*Module) ChangeVersion ¶
ChangeVersion returns a copy of m with a different version.
func (*Module) DeleteFile ¶
DeleteFile returns a copy of m with filename removed. It panics if filename is not present.
func (*Module) ReplaceFile ¶
ReplaceFile returns a copy of m with different contents for filename. It panics if filename is not present.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a proxy server containing the specified modules.
func (*Server) AddModuleNoVersions ¶
AddModuleNoVersions adds a module to the server, but the @v/list endpoint will return nothing and @latest endpoint will serve a 410. For testing the unusual case where a module exists but there is no version information.