Documentation ¶
Overview ¶
Package setup provides integration tests setup helpers.
Index ¶
- func Dir(tb testtb.TB) string
- func FailsForFerretDB(tb testtb.TB, url string) testtb.TB
- func FailsForMongoDB(tb testtb.TB, reason string) testtb.TB
- func IsHana(tb testtb.TB) bool
- func IsMongoDB(tb testtb.TB) bool
- func IsPostgreSQL(tb testtb.TB) bool
- func IsSQLite(tb testtb.TB) bool
- func PushdownDisabled() bool
- func Setup(tb testtb.TB, providers ...shareddata.Provider) (context.Context, *mongo.Collection)
- func SetupCompat(tb testtb.TB) (context.Context, []*mongo.Collection, []*mongo.Collection)
- func Shutdown()
- func SkipForMongoDB(tb testtb.TB, reason string)deprecated
- func Startup()
- type BackendOpts
- type SetupCompatOpts
- type SetupCompatResult
- type SetupOpts
- type SetupResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FailsForFerretDB ¶
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 ¶
FailsForMongoDB return testtb.TB that expects test to fail for MongoDB and pass for FerretDB.
This function should not be used lightly.
func IsHana ¶
IsHana returns true if the current test is running for Hana backend.
This function should not be used lightly.
func IsMongoDB ¶
IsMongoDB returns true if the current test is running for MongoDB.
This function should not be used lightly.
func IsPostgreSQL ¶
IsPostgreSQL returns true if the current test is running for PostgreSQL backend.
This function should not be used lightly.
func IsSQLite ¶
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 SkipForMongoDB
deprecated
SkipForMongoDB skips the current test for MongoDB.
Deprecated: Use FailsForMongoDB in new code.
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.