Skip to content

Add test coverage for legacy iOS database import + migration orchestr… - #1042

Merged
davecraig merged 3 commits into
Scottish-Tech-Army:mainfrom
davecraig:main
Aug 27, 2026
Merged

Add test coverage for legacy iOS database import + migration orchestr…#1042
davecraig merged 3 commits into
Scottish-Tech-Army:mainfrom
davecraig:main

Conversation

@davecraig

Copy link
Copy Markdown
Contributor

…ation

Splits LegacyMigrator.importDatabase into a pure buildLegacyPayload(realm:) (Realm -> JSON, no Room writes) plus a thin importLegacyDatabase(at:) wrapper, drops private from deleteLegacyArtefacts, and parameterizes runIfNeeded (defaults/documentsPath/importDatabase, all defaulting to production behaviour) so each is independently testable without touching real Realm/Room/UserDefaults.standard state.

Adds LegacyMigratorDatabaseTests.swift: 19 cases covering payload building (marker field mapping, isTemp exclusion, name-fallback chain, waypoint ordering, unresolvable-waypoint route skipping, shared markers across routes, empty realm), artefact deletion, and runIfNeeded's four branches (fresh install, successful import, failed import retry, already done).

Unverified locally - no macOS/Xcode toolchain available in this environment; needs an xcodebuild run before this is trusted.

…ation

Splits LegacyMigrator.importDatabase into a pure buildLegacyPayload(realm:)
(Realm -> JSON, no Room writes) plus a thin importLegacyDatabase(at:)
wrapper, drops `private` from deleteLegacyArtefacts, and parameterizes
runIfNeeded (defaults/documentsPath/importDatabase, all defaulting to
production behaviour) so each is independently testable without touching
real Realm/Room/UserDefaults.standard state.

Adds LegacyMigratorDatabaseTests.swift: 19 cases covering payload building
(marker field mapping, isTemp exclusion, name-fallback chain, waypoint
ordering, unresolvable-waypoint route skipping, shared markers across
routes, empty realm), artefact deletion, and runIfNeeded's four branches
(fresh install, successful import, failed import retry, already done).

Unverified locally - no macOS/Xcode toolchain available in this environment;
needs an xcodebuild run before this is trusted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
LegacyMigratorDatabaseTests builds its fixtures with RealmSwift, but the
iosAppTests target only depended on the iosApp target. Package products
aren't inherited across a target dependency, so the xctest bundle had no
RealmSwift to link against and `xcodebuild build-for-testing` failed with
undefined symbols (Realm.init(configuration:queue:), _RLMRealmPathForFile,
...) for arm64.

Add the package to the test target with `embed: false` -- the host app
already embeds the framework and the bundle loads inside Soundscape.app.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The single `test` job ran the unit tests, built the debug APK and then ran
the instrumentation tests on an emulator, all in series. The two test
suites don't depend on each other, so split them into `unit-test` and
`instrumentation-test`, which run in parallel alongside lint and ios-test.

Both jobs fetch the offline map fixtures -- the unit tests read them out
of the test resources and the instrumentation job pushes one onto the
emulator -- but that step is cached, so the duplicate fetch is cheap.
assembleDebug stays ahead of the emulator step in the instrumentation job
so the slow Gradle work doesn't run with an emulator sitting open.

Note that the `main` ruleset still requires a status check named `test`,
which no longer exists; the required checks need updating to the new job
names before this can merge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@davecraig
davecraig merged commit e783c2c into Scottish-Tech-Army:main Aug 27, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant