mockgcptests

package
v0.0.0-...-bead1b6 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
)

Variables

This section is empty.

Functions

func GetDefaultProjectID

func GetDefaultProjectID(t *testing.T) string

GetDefaultProjectID returns the ID of user's configured default GCP project.

func GetProjectNumber

func GetProjectNumber(ctx context.Context, projectID string) (int64, error)

Types

type GCPProject

type GCPProject struct {
	ProjectID     string
	ProjectNumber int64
}

func GetDefaultProject

func GetDefaultProject(t *testing.T) GCPProject

GetDefaultProject returns the ID of user's configured default GCP project.

type GcloudConfig

type GcloudConfig struct {
	EnvVars []string
}

func (*GcloudConfig) AddConfig

func (c *GcloudConfig) AddConfig(key string, value string)

type Harness

type Harness struct {
	*testing.T

	MockGCP mockgcp.Interface

	HTTPClient *http.Client

	Ctx context.Context

	Events *test.MemoryEventSink

	Project GCPProject

	// GRPCUnaryClientInterceptor is the GRPC interceptor for use in tests.
	GRPCUnaryClientInterceptor grpc.UnaryClientInterceptor

	Endpoint string

	GcloudConfiguration string

	ProxyEndpoint *net.TCPAddr
	// contains filtered or unexported fields
}

func NewHarness

func NewHarness(t *testing.T) *Harness

func (*Harness) CompareGoldenFile

func (h *Harness) CompareGoldenFile(p string, got string, normalizers ...func(s string) string)

func (*Harness) Init

func (t *Harness) Init()

func (*Harness) RegisteredServices

func (h *Harness) RegisteredServices() mockgcpregistry.Normalizer

func (*Harness) RunCommand

func (t *Harness) RunCommand(cmdline string)

func (*Harness) StartProxy

func (t *Harness) StartProxy()

type Proxy

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

func NewProxy

func NewProxy(httpClient *http.Client) *Proxy

func (*Proxy) BuildGcloudConfig

func (p *Proxy) BuildGcloudConfig(proxyEndpoint *net.TCPAddr, mockgcp mockgcp.Interface) GcloudConfig

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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