Documentation ¶
Overview ¶
Package testutil provides utilities that are intended to enable easier and more concise writing of unit test code.
Index ¶
- func JWTFromClaims(tb testing.TB, claims map[string]any) string
- func NewRequest(opts ...RequestOptions) *api.AuditLogRequest
- func TestFakeGRPCServer(tb testing.TB, registerFunc func(*grpc.Server)) (string, *grpc.ClientConn)
- type RequestOptions
- func WithLabels(labels map[string]string) RequestOptions
- func WithMetadata(metadata *structpb.Struct) RequestOptions
- func WithMethodName(method string) RequestOptions
- func WithMode(mode api.AuditLogRequest_LogMode) RequestOptions
- func WithPrincipal(principal string) RequestOptions
- func WithServiceName(service string) RequestOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JWTFromClaims ¶
JWTFromClaims is a testing helper that builds a JWT from the given claims.
func NewRequest ¶
func NewRequest(opts ...RequestOptions) *api.AuditLogRequest
func TestFakeGRPCServer ¶
TestFakeGRPCServer creates and registers a fake grpc server for testing. It returns the bound address and a connected client. It ensures the server is stopped when tests finish. It returns an error if the connection does not establish.
Types ¶
type RequestOptions ¶
type RequestOptions func(r *api.AuditLogRequest) *api.AuditLogRequest
func WithLabels ¶
func WithLabels(labels map[string]string) RequestOptions
func WithMetadata ¶
func WithMetadata(metadata *structpb.Struct) RequestOptions
func WithMethodName ¶
func WithMethodName(method string) RequestOptions
func WithMode ¶
func WithMode(mode api.AuditLogRequest_LogMode) RequestOptions
func WithPrincipal ¶
func WithPrincipal(principal string) RequestOptions
func WithServiceName ¶
func WithServiceName(service string) RequestOptions
Click to show internal directories.
Click to hide internal directories.