util

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package util contains utility functions. Most generally, functions that generate random instances of structs for the purposes of testing. This prevents using hard coded values in unit tests which can create copy/paste bugs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateExpandedMapClaims added in v1.3.3

func GenerateExpandedMapClaims() jwt.MapClaims

GenerateExpandedMapClaims returns a random

func GenerateRandomAPIGatewayContext

func GenerateRandomAPIGatewayContext() events.APIGatewayProxyRequestContext

GenerateRandomAPIGatewayContext returns a random instance of events.APIGatewayProxyRequestContext for testing purposes.

func GenerateRandomAPIGatewayProxyRequest

func GenerateRandomAPIGatewayProxyRequest() events.APIGatewayProxyRequest

GenerateRandomAPIGatewayProxyRequest returns a random instance of events.APIGatewayProxyRequest instance for testing purposes.

func GenerateRandomInt

func GenerateRandomInt(N, M int) int

GenerateRandomInt returns a random integer between N and M (inclusive) for testing purposes.

func GenerateRandomString

func GenerateRandomString(n int) string

GenerateRandomString returns a random string of length N for testing purposes.

func GenerateStandardMapClaims added in v1.3.3

func GenerateStandardMapClaims() jwt.MapClaims

func WrapErrors added in v1.3.3

func WrapErrors(err1, err2 error) error

Types

type MockConst added in v1.3.3

type MockConst string

type MockGetReq added in v1.3.3

type MockGetReq struct {
	ID            string `lambda:"path.id"`
	ShowSomething bool   `lambda:"query.show_something"`
}

type MockItem added in v1.3.3

type MockItem struct {
	ID   string
	Name string
	Date time.Time
}

type MockListReq added in v1.3.3

type MockListReq struct {
	Alias         StringAliasExample    `lambda:"query.alias"`
	AliasPtr      *StringAliasExample   `lambda:"query.alias_ptr"`
	Bool1         bool                  `lambda:"query.bool1"`
	Bool2         bool                  `lambda:"query.bool2"`
	Bool3         bool                  `lambda:"query.bool3"`
	Bool4         bool                  `lambda:"query.bool4"`
	Bool5         bool                  `lambda:"query.bool5"`
	Bool6         bool                  `lambda:"query.bool6"`
	Bool7         bool                  `lambda:"query.bool7"`
	Bool8         bool                  `lambda:"query.bool8"`
	Bool9         bool                  `lambda:"query.bool9"`
	Civil         civil.Date            `lambda:"query.civil"`
	CivilPtr      *civil.Date           `lambda:"query.civilPtr"`
	CivilPtrNil   *civil.Date           `lambda:"query.civilPtrNil"`
	CommaSplit    []Number              `lambda:"query.commaSplit"`
	CommaSplitPtr []*Number             `lambda:"query.commaSplitPtr"`
	Const         MockConst             `lambda:"query.const"`
	ConstPtr      *MockConst            `lambda:"query.constPtr"`
	ConstPtrNil   *MockConst            `lambda:"query.constPtrNil"`
	Encoding      []string              `lambda:"header.Accept-Encoding"`
	ID            string                `lambda:"path.id"`
	IDs           []*string             `lambda:"query.ids"`
	Language      string                `lambda:"header.Accept-Language"`
	MongoID       primitive.ObjectID    `lambda:"query.mongoId"`
	MongoIDPtr    *primitive.ObjectID   `lambda:"query.mongoIdPtr"`
	MongoIDPtrNil *primitive.ObjectID   `lambda:"query.mongoIdPtrNil"`
	MongoIDs      []primitive.ObjectID  `lambda:"query.mongoIds"`
	MongoIDsPtr   []*primitive.ObjectID `lambda:"query.mongoIdsPtr"`
	Number        *float32              `lambda:"query.number"`
	Numbers       []float64             `lambda:"query.numbers"`
	PBoolOne      *bool                 `lambda:"query.pbool1"`
	PBoolTwo      *bool                 `lambda:"query.pbool2"`
	Page          int64                 `lambda:"query.page"`
	PageSize      *int64                `lambda:"query.page_size"`
	Terms         []string              `lambda:"query.terms"`
	Time          time.Time             `lambda:"query.time"`
	TimePtr       *time.Time            `lambda:"query.timePtr"`
	TimePtrNil    *time.Time            `lambda:"query.timePtrNil"`
}

type MockPostReq added in v1.3.3

type MockPostReq struct {
	ID   string    `lambda:"path.id"`
	Name string    `json:"name"`
	Date time.Time `json:"date"`
}

type Number added in v1.3.3

type Number string

type StringAliasExample added in v1.3.3

type StringAliasExample string

Jump to

Keyboard shortcuts

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