Documentation ¶
Overview ¶
Package testutil contains helper functions for writing tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶ added in v0.11.0
Diff reports the differences between two values. Diff(x, y) == "" iff Equal(x, y).
func IgnoreUnexported ¶ added in v0.11.0
IgnoreUnexported returns an Option that only ignores the immediate unexported fields of a struct, including anonymous fields of unexported types. In particular, unexported fields within the struct's exported fields of struct types, including anonymous fields, will not be ignored unless the type of the field itself is also passed to IgnoreUnexported.
func ProjID ¶
func ProjID() string
ProjID returns the project ID to use in integration tests, or the empty string if none is configured.
func TokenSource ¶
func TokenSource(ctx context.Context, scopes ...string) oauth2.TokenSource
TokenSource returns the OAuth2 token source to use in integration tests, or nil if none is configured. If the environment variable is unset, TokenSource will try to find 'Application Default Credentials'. Else, TokenSource will return nil. TokenSource will log.Fatal if the token source is specified but missing or invalid.
Types ¶
type Server ¶
A Server is an in-process gRPC server, listening on a system-chosen port on the local loopback interface. Servers are for testing only and are not intended to be used in production code.
To create a server, make a new Server, register your handlers, then call Start:
srv, err := NewServer() ... mypb.RegisterMyServiceServer(srv.Gsrv, &myHandler) .... srv.Start()
Clients should connect to the server with no security:
conn, err := grpc.Dial(srv.Addr, grpc.WithInsecure()) ...
type UIDSpace ¶ added in v0.8.0
type UIDSpace struct { Prefix string // contains filtered or unexported fields }
A UIDSpace manages a set of unique IDs distinguished by a prefix.
func NewUIDSpace ¶ added in v0.8.0
func (*UIDSpace) New ¶ added in v0.8.0
New generates a new unique ID . The ID consists of the UIDSpace's prefix, a timestamp, and a counter value. All unique IDs generated in the same test execution will have the same timestamp.
Aside from the characters in the prefix, IDs contain only letters, numbers and hyphens.