setup

package
v0.0.0-...-2da27aa Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package setup provides integration tests setup helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(tb testtb.TB) string

Dir returns the absolute directory of this package.

func FailsForFerretDB

func FailsForFerretDB(tb testtb.TB, url string) testtb.TB

FailsForFerretDB return testtb.TB that expects test to fail for FerretDB and pass for MongoDB.

This function should not be used lightly and always with an issue URL.

func FailsForMongoDB

func FailsForMongoDB(tb testtb.TB, reason string) testtb.TB

FailsForMongoDB return testtb.TB that expects test to fail for MongoDB and pass for FerretDB.

This function should not be used lightly.

func IsHana

func IsHana(tb testtb.TB) bool

IsHana returns true if the current test is running for Hana backend.

This function should not be used lightly.

func IsMongoDB

func IsMongoDB(tb testtb.TB) bool

IsMongoDB returns true if the current test is running for MongoDB.

This function should not be used lightly.

func IsPostgreSQL

func IsPostgreSQL(tb testtb.TB) bool

IsPostgreSQL returns true if the current test is running for PostgreSQL backend.

This function should not be used lightly.

func IsSQLite

func IsSQLite(tb testtb.TB) bool

IsSQLite returns true if the current test is running for SQLite backend.

This function should not be used lightly.

func PushdownDisabled

func PushdownDisabled() bool

PushdownDisabled returns true if FerretDB pushdown is disabled.

func Setup

func Setup(tb testtb.TB, providers ...shareddata.Provider) (context.Context, *mongo.Collection)

Setup setups a single collection for all providers, if they are present.

func SetupCompat

func SetupCompat(tb testtb.TB) (context.Context, []*mongo.Collection, []*mongo.Collection)

SetupCompat setups compatibility test.

func Shutdown

func Shutdown()

Shutdown cleans up after all tests.

func SkipForMongoDB deprecated

func SkipForMongoDB(tb testtb.TB, reason string)

SkipForMongoDB skips the current test for MongoDB.

Deprecated: Use FailsForMongoDB in new code.

func Startup

func Startup()

Startup initializes things that should be initialized only once.

Types

type BackendOpts

type BackendOpts struct {
	// Capped collections cleanup interval.
	CappedCleanupInterval time.Duration

	// Percentage of documents to cleanup for capped collections. If not set, defaults to 20.
	CappedCleanupPercentage uint8
}

BackendOpts represents backend configuration used for test setup.

func NewBackendOpts

func NewBackendOpts() *BackendOpts

NewBackendOpts returns BackendOpts with default values set.

type SetupCompatOpts

type SetupCompatOpts struct {
	// Data providers.
	Providers []shareddata.Provider

	// If true, a non-existent collection will be added to the list of collections.
	// This is useful to test the behavior when a collection is not found.
	//
	// This flag is not needed, always add a non-existent collection.
	// TODO https://github.com/FerretDB/FerretDB/issues/1545
	AddNonExistentCollection bool
	// contains filtered or unexported fields
}

SetupCompatOpts represents setup options for compatibility test.

Add option to use read-only user. TODO https://github.com/FerretDB/FerretDB/issues/1025

type SetupCompatResult

type SetupCompatResult struct {
	Ctx               context.Context
	TargetCollections []*mongo.Collection
	CompatCollections []*mongo.Collection
}

SetupCompatResult represents compatibility test setup results.

func SetupCompatWithOpts

func SetupCompatWithOpts(tb testtb.TB, opts *SetupCompatOpts) *SetupCompatResult

SetupCompatWithOpts setups the compatibility test according to given options.

type SetupOpts

type SetupOpts struct {
	// Database to use. If empty, temporary test-specific database is created and dropped after test.
	DatabaseName string

	// Collection to use. If empty, temporary test-specific collection is created and dropped after test.
	// Most tests should keep this empty.
	CollectionName string

	// Data providers. If empty, collection is not created.
	Providers []shareddata.Provider

	// Benchmark data provider. If empty, collection is not created.
	BenchmarkProvider shareddata.BenchmarkProvider

	// ExtraOptions sets the options in MongoDB URI, when the option exists it overwrites that option.
	ExtraOptions url.Values

	// SetupUser true creates a user and returns an authenticated client.
	SetupUser bool

	// Options to override default backend configuration.
	BackendOptions *BackendOpts
}

SetupOpts represents setup options.

Add option to use read-only user. TODO https://github.com/FerretDB/FerretDB/issues/1025

type SetupResult

type SetupResult struct {
	Ctx        context.Context
	Collection *mongo.Collection
	MongoDBURI string
}

SetupResult represents setup results.

func SetupWithOpts

func SetupWithOpts(tb testtb.TB, opts *SetupOpts) *SetupResult

SetupWithOpts setups the test according to given options.

func (*SetupResult) IsUnixSocket

func (s *SetupResult) IsUnixSocket(tb testtb.TB) bool

IsUnixSocket returns true if MongoDB URI is a Unix domain socket.

Jump to

Keyboard shortcuts

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