|
184 | 184 | popd >/dev/null |
185 | 185 | } |
186 | 186 |
|
| 187 | +@test "fetch-db: Resolve indexed dir from plain VORTEX_DB_DIR fallback" { |
| 188 | + pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 |
| 189 | + |
| 190 | + # The migration DB (index 2) has a per-index file name (db2.sql) but no |
| 191 | + # per-index directory, so the non-indexed VORTEX_DB_DIR must act as the base |
| 192 | + # directory. An existing dump placed there should be discovered. |
| 193 | + mkdir -p custom_data |
| 194 | + touch custom_data/db2.sql |
| 195 | + |
| 196 | + mock_ls=$(mock_command "ls") |
| 197 | + mock_set_output "${mock_ls}" "total 0" 1 |
| 198 | + |
| 199 | + export VORTEX_DB_INDEX="2" |
| 200 | + export VORTEX_FETCH_DB2_SOURCE="url" |
| 201 | + export VORTEX_FETCH_DB2_PROCEED="1" |
| 202 | + # Set the per-index file name explicitly so the fixture name matches the |
| 203 | + # resolved dump file rather than relying on the fixture .env default. |
| 204 | + export VORTEX_FETCH_DB2_FILE="db2.sql" |
| 205 | + export VORTEX_DB_DIR="custom_data" |
| 206 | + |
| 207 | + run .vortex/tooling/src/vortex-fetch-db |
| 208 | + assert_success |
| 209 | + # The router resolved the indexed dump directory to custom_data via the |
| 210 | + # plain VORTEX_DB_DIR fallback and found the existing dump there. |
| 211 | + assert_output_contains "Found existing database dump file(s)." |
| 212 | + assert_output_contains "Using existing database dump file(s)." |
| 213 | + |
| 214 | + popd >/dev/null |
| 215 | +} |
| 216 | + |
| 217 | +@test "fetch-db: Resolve indexed file name from plain VORTEX_DB_FILE fallback" { |
| 218 | + pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 |
| 219 | + |
| 220 | + # An index with no per-index file override (unlike index 2, which the fixture |
| 221 | + # sets to db2.sql) must fall back to the non-indexed VORTEX_DB_FILE for the |
| 222 | + # dump file name. An existing dump with that name should be discovered. |
| 223 | + mkdir -p .data |
| 224 | + touch .data/custom.sql |
| 225 | + |
| 226 | + mock_ls=$(mock_command "ls") |
| 227 | + mock_set_output "${mock_ls}" "total 0" 1 |
| 228 | + |
| 229 | + export VORTEX_DB_INDEX="3" |
| 230 | + export VORTEX_FETCH_DB3_SOURCE="url" |
| 231 | + export VORTEX_FETCH_DB3_PROCEED="1" |
| 232 | + export VORTEX_DB_FILE="custom.sql" |
| 233 | + |
| 234 | + run .vortex/tooling/src/vortex-fetch-db |
| 235 | + assert_success |
| 236 | + # The router resolved the indexed dump file name to custom.sql via the |
| 237 | + # plain VORTEX_DB_FILE fallback and found the existing dump. |
| 238 | + assert_output_contains "Found existing database dump file(s)." |
| 239 | + |
| 240 | + popd >/dev/null |
| 241 | +} |
| 242 | + |
187 | 243 | @test "fetch-db: Existing database file handling" { |
188 | 244 | pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 |
189 | 245 |
|
|
0 commit comments