Documentation ¶
Overview ¶
Package testutils is test helpers for packages.
Index ¶
- func ValidateContentsOfPPackage(t *testing.T, dir string)
- type FakePackagesClientAndGCSServer
- func (c *FakePackagesClientAndGCSServer) Addr() net.Addr
- func (c *FakePackagesClientAndGCSServer) Clear()
- func (c *FakePackagesClientAndGCSServer) Client(ctx context.Context) (pb.PackageServiceClient, rpc.ClientConn, error)
- func (c *FakePackagesClientAndGCSServer) GetPackage(ctx context.Context, in *pb.GetPackageRequest) (*pb.GetPackageResponse, error)
- func (c *FakePackagesClientAndGCSServer) RequestCounts() (req, download int)
- func (c *FakePackagesClientAndGCSServer) SetInvalidChecksum(flag bool)
- func (c *FakePackagesClientAndGCSServer) SetInvalidHTTPRes(flag bool)
- func (c *FakePackagesClientAndGCSServer) SetInvalidTar(flag bool)
- func (c *FakePackagesClientAndGCSServer) Shutdown() error
- func (c *FakePackagesClientAndGCSServer) StorePackage(all ...config.PackageConfig)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateContentsOfPPackage ¶
ValidateContentsOfPPackage validates the expected uncompressed / unzipped contents of the test package returned from the fake server.
Contents: . ├── some-link.txt -> sub-dir/sub-file.txt ├── some-text.txt (crc32c:p_E54w==) ├── some-text2.txt (crc32c:p_E54w==) ├── sub-dir │ └── sub-file.txt (crc32c:p_E54w==) └── sub-dir-link -> sub-dir.
Types ¶
type FakePackagesClientAndGCSServer ¶
type FakePackagesClientAndGCSServer struct { pb.UnimplementedPackageServiceServer // contains filtered or unexported fields }
FakePackagesClientAndGCSServer to act as a stubbed client for the PackageServiceClient and host a fake server to serve HTTP get requests for the actual package tar.
func NewFakePackageServer ¶
func NewFakePackageServer(ctx context.Context, logger logging.Logger) (*FakePackagesClientAndGCSServer, error)
NewFakePackageServer creates a new fake package server.
func (*FakePackagesClientAndGCSServer) Addr ¶
func (c *FakePackagesClientAndGCSServer) Addr() net.Addr
Addr returns the listeners address.
func (*FakePackagesClientAndGCSServer) Clear ¶
func (c *FakePackagesClientAndGCSServer) Clear()
Clear resets the fake servers state, does not restart the server.
func (*FakePackagesClientAndGCSServer) Client ¶
func (c *FakePackagesClientAndGCSServer) Client(ctx context.Context) (pb.PackageServiceClient, rpc.ClientConn, error)
Client returns a connect client to the server and connection.
func (*FakePackagesClientAndGCSServer) GetPackage ¶
func (c *FakePackagesClientAndGCSServer) GetPackage(ctx context.Context, in *pb.GetPackageRequest) (*pb.GetPackageResponse, error)
GetPackage returns the URL and metadata for a requested package version.
func (*FakePackagesClientAndGCSServer) RequestCounts ¶
func (c *FakePackagesClientAndGCSServer) RequestCounts() (req, download int)
RequestCounts returns the request counters.
func (*FakePackagesClientAndGCSServer) SetInvalidChecksum ¶
func (c *FakePackagesClientAndGCSServer) SetInvalidChecksum(flag bool)
SetInvalidChecksum sets failure state.
func (*FakePackagesClientAndGCSServer) SetInvalidHTTPRes ¶
func (c *FakePackagesClientAndGCSServer) SetInvalidHTTPRes(flag bool)
SetInvalidHTTPRes sets failure state.
func (*FakePackagesClientAndGCSServer) SetInvalidTar ¶
func (c *FakePackagesClientAndGCSServer) SetInvalidTar(flag bool)
SetInvalidTar sets failure state.
func (*FakePackagesClientAndGCSServer) Shutdown ¶
func (c *FakePackagesClientAndGCSServer) Shutdown() error
Shutdown will stop the server.
func (*FakePackagesClientAndGCSServer) StorePackage ¶
func (c *FakePackagesClientAndGCSServer) StorePackage(all ...config.PackageConfig)
StorePackage store pacakges to known to fake server.