apache / apache/texera

refactor(test): extract shared DB provisioning helper for TestUtils and MockTexeraDB

Open
#6,421 2 comments 0 reactions 1 assignee Claimed by @VuMartin View on GitHub
Dominant language
Scala
Stars
314
Forks
187
Avg merge
1d 21h
Merged PRs (30d)
214

Description

### Task Summary

### Task Summary
Part of #6238, refactor MockTexeraDB into a JVM singleton.
This sub-issue covers deduplicating the test database provisioning logic specifically. Currently, the "create database + run DDL" sequence is implemented in two places: `TestUtils.initiateTexeraDBForTestCases` for test cases and `MockTexeraDB.initializeDBAndReplaceDSLContext`. The two copies have already drifted from each other. This task consolidates them into a single shared helper.

### Scope
Extract a shared provisioning helper that:

- Creates an isolated per-suite/test database on the embedded Postgres instance via CREATE DATABASE
Runs the cached DDL script against the newly created database
- Is exposed as a single reusable method on object MockTexeraDB so both TestUtils and the trait call the same code path

### Constraints:

- Existing functionality must be preserved exactly this is an internal refactor/cleanup, not a behavior change.
- Both call sites (`TestUtils.initiateTexeraDBForTestCases` and `MockTexeraDB.initializeDBAndReplaceDSLContext`) - should route through the shared helper, eliminating the drift.
- No change to the connection lifecycle guarantees introduced in #6238 (e.g. DDL connections still closed via Using.resource, no leaks on failure).

See #6238 (review thread on TestUtils.scala) for the original discussion where this cleanup was agreed to be split out as a follow-up.

### Task Type

- [x] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [ ] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.