common_testing

package
v0.0.0-...-a9ce3c6 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(e error, desc string)

CheckErr checks error in a single line of code.

func CmpAssertEqual

func CmpAssertEqual(t *testing.T, want interface{}, test interface{}, opts ...cmp.Option)

CmpAssertEqual allows to test if two objects are equal, using go-cmp. opts refer to options to pass to the cmp.Equal() function. Can be stuff like cmpopts.IgnoreUnexported() or cmpopts.EquateErrors()

func ContextGenerator

func ContextGenerator(ctx context.Context, service, method, port string, req interface{}, res interface{}) (interface{}, error)

ContextGenerator aims to create a testing context (ONLY FOR DEV AND TEST MODE). "ctx" is the context, it can contain attached metadatas. It MUST be outgoing. "service" is the name of the service, but the value has often the format "package.Service" => auth.AuthService for example. "method" is the name of the method. "port" is the port at which the services is exposed. "req" is the request, but declared like req := &authpb.CreateNewUserRequest{Username:..., Email: ...} the & is really important "res" is the response, must be like res := &authpb.CreateNewUserResponse{}, the & is really important. The res variable will be modified by reference !

func LoadFromKvdb

func LoadFromKvdb(bucketName string, key string) string

LoadFromKvdb allows to load from the testing kvdb in one line of code

func PrepareCtxWithToken

func PrepareCtxWithToken(username string) (context.Context, context.Context)

PrepareCtxWithToken returns a ctx with an embedded authorization token. First one is Incoming, second is OutGoing.

func SaveToKvdb

func SaveToKvdb(bucketName string, key string, value string)

SaveToKvdb allows to save to the testing kvdb in one line of code

Types

This section is empty.

Jump to

Keyboard shortcuts

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