testutils

package
v0.29.0-rc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package testutils is test helpers for packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateContentsOfPPackage

func ValidateContentsOfPPackage(t *testing.T, dir string)

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

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

Client returns a connect client to the server and connection.

func (*FakePackagesClientAndGCSServer) GetPackage

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) SetChecksumWithLeadingZeroes added in v0.24.0

func (c *FakePackagesClientAndGCSServer) SetChecksumWithLeadingZeroes(flag bool)

SetChecksumWithLeadingZeroes sets checksum to a valid checksum with leading zeroes.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL