bbfake

package
v0.0.0-...-a8f2654 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package bbfake implements fake Buildbucket server and the client connects to the fake for needs of CV tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildConstructor

type BuildConstructor struct {
	// contains filtered or unexported fields
}

BuildConstructor provides fluent APIs to reduce the boilerplate when constructing test build.

func NewBuildConstructor

func NewBuildConstructor() *BuildConstructor

NewBuildConstructor creates a new constructor from scratch.

func NewConstructorFromBuild

func NewConstructorFromBuild(build *bbpb.Build) *BuildConstructor

NewConstructorFromBuild creates a new constructor with initial value populated based on the provided build.

Providing nil build is equivalent to `NewBuildConstructor()`

func (*BuildConstructor) AppendGerritChanges

func (bc *BuildConstructor) AppendGerritChanges(gcs ...*bbpb.GerritChange) *BuildConstructor

AppendGerritChanges appends Gerrit changes to this build. Optional.

func (*BuildConstructor) Construct

func (bc *BuildConstructor) Construct() *bbpb.Build

Construct creates a new build based on supplied inputs.

func (*BuildConstructor) ResetGerritChanges

func (bc *BuildConstructor) ResetGerritChanges() *BuildConstructor

ResetGerritChanges clears all existing Gerrit Changes of this build.

func (*BuildConstructor) WithBuilderID

func (bc *BuildConstructor) WithBuilderID(builderID *bbpb.BuilderID) *BuildConstructor

WithBuilderID specifies the Builder. Required.

func (*BuildConstructor) WithCreateTime

func (bc *BuildConstructor) WithCreateTime(createTime time.Time) *BuildConstructor

WithCreateTime specifies the create time. Required.

func (*BuildConstructor) WithEndTime

func (bc *BuildConstructor) WithEndTime(endTime time.Time) *BuildConstructor

WithEndTime specifies the end time. Required if status is ended.

func (*BuildConstructor) WithExperimental

func (bc *BuildConstructor) WithExperimental(exp bool) *BuildConstructor

WithExperimental marks this build as experimental build. Optional.

func (*BuildConstructor) WithHost

func (bc *BuildConstructor) WithHost(host string) *BuildConstructor

WithHost specifies the host of this Build. Required.

func (*BuildConstructor) WithID

func (bc *BuildConstructor) WithID(id int64) *BuildConstructor

WithID specifies the Build ID. Required.

func (*BuildConstructor) WithInvocation

func (bc *BuildConstructor) WithInvocation(resultdbHost, inv string) *BuildConstructor

func (*BuildConstructor) WithRequestedProperties

func (bc *BuildConstructor) WithRequestedProperties(data map[string]any) *BuildConstructor

WithRequestedProperties specifies the requested properties. Optional.

The data will be transformed to proto struct format.

func (*BuildConstructor) WithStartTime

func (bc *BuildConstructor) WithStartTime(startTime time.Time) *BuildConstructor

WithStartTime specifies the start time. Required if status >= STARTED.

func (*BuildConstructor) WithStatus

func (bc *BuildConstructor) WithStatus(status bbpb.Status) *BuildConstructor

WithStatus specifies the Build Status. Required.

func (*BuildConstructor) WithSummaryMarkdown

func (bc *BuildConstructor) WithSummaryMarkdown(sm string) *BuildConstructor

WithSummaryMarkdown specifies the summary markdown. Optional

func (*BuildConstructor) WithTimeout

func (bc *BuildConstructor) WithTimeout(isTimeout bool) *BuildConstructor

WithTimeout sets the timeout bit of this build. Optional.

func (*BuildConstructor) WithUpdateTime

func (bc *BuildConstructor) WithUpdateTime(updateTime time.Time) *BuildConstructor

WithUpdateTime specifies the update time. Optional.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client connects a Buildbucket Fake and scope to a certain LUCI Project + Buildbucket host.

func (*Client) Batch

func (c *Client) Batch(ctx context.Context, in *bbpb.BatchRequest, opts ...grpc.CallOption) (*bbpb.BatchResponse, error)

Batch implements buildbucket.Client.

Supports:

  • CancelBuild
  • GetBuild
  • ScheduleBuild

func (*Client) CancelBuild

func (c *Client) CancelBuild(ctx context.Context, in *bbpb.CancelBuildRequest, opts ...grpc.CallOption) (*bbpb.Build, error)

CancelBuild implements buildbucket.Client.

func (*Client) GetBuild

func (c *Client) GetBuild(ctx context.Context, in *bbpb.GetBuildRequest, opts ...grpc.CallOption) (*bbpb.Build, error)

GetBuild implements buildbucket.Client.

func (*Client) ScheduleBuild

func (c *Client) ScheduleBuild(ctx context.Context, in *bbpb.ScheduleBuildRequest) (*bbpb.Build, error)

ScheduleBuild schedules a new build for the provided builder.

The builder should be present in buildbucket fake. It can be added via AddBuilder function.

func (*Client) SearchBuilds

SearchBuilds implements buildbucket.Client.

Support paging and the following predicates:

  • gerrit_changes
  • include_experimental

Use `defaultSearchPageSize` if page size is not specified in the input.

type Fake

type Fake struct {
	// contains filtered or unexported fields
}

func (*Fake) AddBuilder

func (f *Fake) AddBuilder(host string, builder *bbpb.BuilderID, properties any) *Fake

AddBuilder adds a new builder configuration to fake Buildbucket host.

Overwrites the existing builder if the same builder already exists. `properties` should be marshallable by `encoding/json`.

func (*Fake) EnsureBuilders

func (f *Fake) EnsureBuilders(cfg *cfgpb.Config)

EnsureBuilders ensures all builders defined in the Project config are added to the Buildbucket fake.

func (*Fake) MustNewClient

func (f *Fake) MustNewClient(ctx context.Context, host, luciProject string) *Client

MustNewClient is a shorthand of `fake.NewClientFactory().MakeClient(...)`.

Panics if fails to create new client.

func (*Fake) MutateBuild

func (f *Fake) MutateBuild(ctx context.Context, host string, id int64, mutateFn func(*bbpb.Build)) *bbpb.Build

MutateBuild mutates the provided build.

Panics if the provided build is not found.

func (*Fake) NewClientFactory

func (f *Fake) NewClientFactory() buildbucket.ClientFactory

NewClientFactory returns a factory that creates a client for this buildbucket fake.

func (*Fake) RegisterPubsubTopic

func (f *Fake) RegisterPubsubTopic(host string, topic *pubsub.Topic)

RegisterPubsubTopic registers a pubsub topic for the given host.

If a build is updated to the terminal status, a message will be sent to the topic for this build.

Jump to

Keyboard shortcuts

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