testutils

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const LocalhostMongoDB = "localhost:27017"

Variables

This section is empty.

Functions

func AssertResponseError

func AssertResponseError(t *testing.T, resp *httptest.ResponseRecorder, statusCode int, technicalErrMsg string)

func AssertResponseFullErrorMessages

func AssertResponseFullErrorMessages(t *testing.T, resp *httptest.ResponseRecorder, statusCode int, technicalErrMsg, businessErrMsg string)

func GetAndDisposeTestClientsAndCollections

func GetAndDisposeTestClientsAndCollections(t *testing.T) (*mongo.Client, string, *mongo.Collection, *mongo.Collection)

GetAndDisposeTestCollection returns a collection from a random database. The function performs test clean up by dropping the database and closing MongoDB client connection.

func GetDBAndCollections

func GetDBAndCollections(t *testing.T, client *mongo.Client) (*mongo.Database, *mongo.Collection, *mongo.Collection)

GetDBAndCollections returns a random database and collection. The function does not perform any cleanup, you have to manually disconnect from the client.

func GetMongoClient

func GetMongoClient(t *testing.T) *mongo.Client

GetMongoClient returns a mongodb client. The function does not perform any cleanup, you have to manually disconnect from the client.

func GetRandomName

func GetRandomName(n int) string

func PopulateDBForTesting

func PopulateDBForTesting(
	t *testing.T,
	ctx context.Context,
	rolesCollection *mongo.Collection,
	bindingsCollection *mongo.Collection,
)

#nosec G104 -- Ignored errors

Types

This section is empty.

Jump to

Keyboard shortcuts

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