testutil

package
v0.0.0-...-9d66df0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPortNumber

func GetPortNumber(base int) int

GetPortNumber returns a new port number that has not been used in the current runtime.

Types

type MockBuildloggerServer

type MockBuildloggerServer struct {
	Mu        sync.Mutex
	CreateErr bool
	AppendErr bool
	CloseErr  bool
	Create    *gopb.LogData
	Data      map[string][]*gopb.LogLines
	Close     *gopb.LogEndInfo
	DialOpts  timber.DialCedarOptions

	// UnimplementedBuildloggerServer must be embedded for forward
	// compatibility. See gopb.buildlogger_grpc.pb.go for more information.
	gopb.UnimplementedBuildloggerServer
}

MockBuildloggerServer sets up a mock Cedar server for testing buildlogger logs using gRPC.

func NewMockBuildloggerServer

func NewMockBuildloggerServer(ctx context.Context, basePort int) (*MockBuildloggerServer, error)

NewMockBuildloggerServer returns a new MockBuildloggerServer listening on a port near the provided port.

func NewMockBuildloggerServerWithDialOpts

func NewMockBuildloggerServerWithDialOpts(ctx context.Context, opts timber.DialCedarOptions) (*MockBuildloggerServer, error)

NewMockBuildloggerServerWithDialOpts returns a new MockBuildloggerServer listening on the port and URL from the specified dial options.

func (*MockBuildloggerServer) Address

func (ms *MockBuildloggerServer) Address() string

Address returns the address the server is listening on.

func (*MockBuildloggerServer) AppendLogLines

AppendLogLines returns an error if AppendErr is true, otherwise it adds the input to Data.

func (*MockBuildloggerServer) CloseLog

CloseLog returns an error if CloseErr is true, otherwise it sets Close to the input.

func (*MockBuildloggerServer) CreateLog

CreateLog returns an error if CreateErr is true, otherwise it sets Create to the input.

func (*MockBuildloggerServer) StreamLogLines

StreamLogLines returns a not implemented error.

type MockCedarServer

type MockCedarServer struct {
	TestResults *MockTestResultsServer
	Buildlogger *MockBuildloggerServer
	Health      *MockHealthServer
	DialOpts    timber.DialCedarOptions
}

MockCedarServer sets up a mock Cedar server for sending metrics, test results, and logs using gRPC.

func NewMockCedarServer

func NewMockCedarServer(ctx context.Context, basePort int) (*MockCedarServer, error)

NewMockCedarServer will return a new MockCedarServer listening on a port near the provided port.

func NewMockCedarServerWithDialOpts

func NewMockCedarServerWithDialOpts(ctx context.Context, opts timber.DialCedarOptions) (*MockCedarServer, error)

NewMockCedarServerWithDialOpts will return a new MockCedarServer listening on the port and URL from the specified dial options.

func (*MockCedarServer) Address

func (ms *MockCedarServer) Address() string

Address returns the address the server is listening on.

type MockHealthServer

type MockHealthServer struct {
	Mu       sync.Mutex
	Status   *gopb.HealthCheckResponse_ServingStatus
	Err      bool
	DialOpts timber.DialCedarOptions

	// UnimplementedHealthServer must be embedded for forward
	// compatibility. See gopb.health_grpc.pb.go for more information.
	gopb.UnimplementedHealthServer
}

MockHealthServer sets up a mock Cedar server for testing the health check gRPC route.

func NewMockHealthServer

func NewMockHealthServer(ctx context.Context, basePort int) (*MockHealthServer, error)

NewMockHealthServer returns a new MockHealthServer listening on a port near near the provided port.

func NewMockHealthServerWithDialOpts

func NewMockHealthServerWithDialOpts(ctx context.Context, opts timber.DialCedarOptions) (*MockHealthServer, error)

NewMockHealthServerWithDialOpts returns a new MockHealthServer listening on the port and URL from the specified dial options.

func (*MockHealthServer) Address

func (ms *MockHealthServer) Address() string

Address returns the address the server is listening on.

func (*MockHealthServer) Check

Check returns (in the following order of precedence) an error if Err is true, Status if it is not empty, and "SERVING" otherwise.

type MockTestResultsServer

type MockTestResultsServer struct {
	CreateErr     bool
	AddErr        bool
	StreamErr     bool
	CloseErr      bool
	Create        *gopb.TestResultsInfo
	Results       map[string][]*gopb.TestResults
	StreamResults map[string][]*gopb.TestResults
	Close         *gopb.TestResultsEndInfo
	DialOpts      timber.DialCedarOptions

	// UnimplementedCedarTestResultsServer must be embedded for forward
	// compatibility. See gopb.test_results_grpc.pb.go for more
	// information.
	gopb.UnimplementedCedarTestResultsServer
}

MockTestResultsServer sets up a mock Cedar server for sending test results using gRPC.

func NewMockTestResultsServer

func NewMockTestResultsServer(ctx context.Context, basePort int) (*MockTestResultsServer, error)

NewMockTestResultsServer returns a new MockTestResultsServer listening on a port near the provided port.

func NewMockTestResultsServerWithDialOpts

func NewMockTestResultsServerWithDialOpts(ctx context.Context, opts timber.DialCedarOptions) (*MockTestResultsServer, error)

NewMockTestResultsServerWithDialOpts returns a new MockTestResultsServer listening on the port and URL from the specified dial options.

func (*MockTestResultsServer) AddTestResults

AddTestResults returns an error if AddErr is true, otherwise it adds the input to Results.

func (*MockTestResultsServer) Address

func (ms *MockTestResultsServer) Address() string

Address returns the address the server is listening on.

func (*MockTestResultsServer) CloseTestResultsRecord

CloseTestResults returns an error if CloseErr is true, otherwise it sets Close to the input.

func (*MockTestResultsServer) CreateTestResultsRecord

func (m *MockTestResultsServer) CreateTestResultsRecord(_ context.Context, in *gopb.TestResultsInfo) (*gopb.TestResultsResponse, error)

CreateTestResultsRecord returns an error if CreateErr is true, otherwise it sets Create to the input.

func (*MockTestResultsServer) StreamTestResults

StreamTestResults returns a not implemented error.

Jump to

Keyboard shortcuts

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