testutil

package
v0.0.0-...-05145c8 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package testutil provides utilities that are intended to enable easier and more concise writing of unit test code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JWTFromClaims

func JWTFromClaims(tb testing.TB, claims map[string]any) string

JWTFromClaims is a testing helper that builds a JWT from the given claims.

func NewRequest

func NewRequest(opts ...RequestOptions) *api.AuditLogRequest

func TestFakeGRPCServer

func TestFakeGRPCServer(tb testing.TB, registerFunc func(*grpc.Server)) (string, *grpc.ClientConn)

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 WithPrincipal

func WithPrincipal(principal string) RequestOptions

func WithServiceName

func WithServiceName(service string) RequestOptions

Jump to

Keyboard shortcuts

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