Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chilagrow committed May 23, 2024
1 parent c0594c8 commit 2ac7eae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions integration/setup/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func listenerMongoDBURI(tb testtb.TB, hostPort, unixSocketPath string, tlsAndAut

// setupListener starts in-process FerretDB server that runs until ctx is canceled.
// It returns basic MongoDB URI for that listener.
func setupListener(tb testtb.TB, ctx context.Context, logger *zap.Logger, opts *BackendOpts, isEnvData bool) string {
func setupListener(tb testtb.TB, ctx context.Context, logger *zap.Logger, opts *BackendOpts, persistData bool) string {

Check warning on line 98 in integration/setup/listener.go

View check run for this annotation

Codecov / codecov/patch

integration/setup/listener.go#L98

Added line #L98 was not covered by tests
tb.Helper()

_, span := otel.Tracer("").Start(ctx, "setupListener")
Expand Down Expand Up @@ -147,14 +147,14 @@ func setupListener(tb testtb.TB, ctx context.Context, logger *zap.Logger, opts *
// use per-test PostgreSQL database to prevent handler's/backend's metadata registry
// read schemas owned by concurrent tests
postgreSQLURLF := *postgreSQLURLF
if postgreSQLURLF != "" && !isEnvData {
if postgreSQLURLF != "" && !persistData {

Check warning on line 150 in integration/setup/listener.go

View check run for this annotation

Codecov / codecov/patch

integration/setup/listener.go#L150

Added line #L150 was not covered by tests
postgreSQLURLF = testutil.TestPostgreSQLURI(tb, ctx, postgreSQLURLF)
}

// use per-test directory to prevent handler's/backend's metadata registry
// read databases owned by concurrent tests
sqliteURL := *sqliteURLF
if sqliteURL != "" && !isEnvData {
if sqliteURL != "" && !persistData {

Check warning on line 157 in integration/setup/listener.go

View check run for this annotation

Codecov / codecov/patch

integration/setup/listener.go#L157

Added line #L157 was not covered by tests
sqliteURL = testutil.TestSQLiteURI(tb, sqliteURL)
}

Expand Down
7 changes: 5 additions & 2 deletions integration/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ type SetupOpts struct {

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

// PersistData modifies the database given by backend url directly
// instead of creating a backend database that is deleted after this test.
PersistData bool
}

// BackendOpts represents backend configuration used for test setup.
Expand Down Expand Up @@ -176,8 +180,7 @@ func SetupWithOpts(tb testtb.TB, opts *SetupOpts) *SetupResult {
opts.BackendOptions.CappedCleanupPercentage = NewBackendOpts().CappedCleanupPercentage
}

isEnvData := opts.DatabaseName == "test"
uri = setupListener(tb, setupCtx, logger, opts.BackendOptions, isEnvData)
uri = setupListener(tb, setupCtx, logger, opts.BackendOptions, opts.PersistData)

Check warning on line 183 in integration/setup/setup.go

View check run for this annotation

Codecov / codecov/patch

integration/setup/setup.go#L183

Added line #L183 was not covered by tests
} else {
uri = toAbsolutePathURI(tb, *targetURLF)
}
Expand Down
1 change: 1 addition & 0 deletions integration/shareddata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestEnvData(t *testing.T) {
DatabaseName: "test",
CollectionName: name,
Providers: []shareddata.Provider{p},
PersistData: true,
})

// envData must persist, other integration tests do not
Expand Down

0 comments on commit 2ac7eae

Please sign in to comment.