Skip to content

test: repair test target after datagrid refactors#920

Closed
datlechin wants to merge 3 commits intomainfrom
fix/test-target-compile
Closed

test: repair test target after datagrid refactors#920
datlechin wants to merge 3 commits intomainfrom
fix/test-target-compile

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

Repairs the TableProTests target so it compiles and runs again. The target had been broken across PRs #914, #915, #917, #918 (datagrid refactors), and surfacing those compile errors also exposed a pre-existing dialect-quoting issue in SQLStatementGenerator. Three focused commits, scoped narrowly to unblock other PRs (including the upcoming raycast-integration work).

In scope (this PR)

1. Compile fix for 4 test files7868fce6. The datagrid refactors renamed APIs but missed:

2. Source-side dialect derivation27e63c47. Once the test target compiled, SQLStatementGenerator*Tests (51 cases) ran for the first time and 100% failed because tests construct the generator with dialect: nil and assert on identifier quoting. quoteIdentifierFromDialect(nil) returns identity. Added resolveSQLDialect(for:explicit:) in DialectQuoteHelper.swift that falls back to PluginMetadataRegistry.shared.snapshot(forTypeId:)?.editor.sqlDialect when no explicit dialect is supplied, and wired SQLStatementGenerator.init through it. Production behavior is unchanged for callers that already pass a dialect; production code that previously had to look up the dialect manually still can. Result: SQLStatementGeneratorTests 49/51 green (the 2 remaining are LIMIT 1 / TOP 1 — see follow-ups).

3. FakeTableOperationProvider test seam57a397fb. Three SaveCompletionTests exited via the empty-statements error path because currentPluginDriverAdapter is nil in tests (no live driver session). Extracted a TableOperationStatementProvider protocol covering the four methods MainContentCoordinator+TableOperations.swift calls (truncateTableStatements, dropObjectStatement, foreignKeyDisableStatements, foreignKeyEnableStatements); PluginDriverAdapter adopts it via empty extension. Added tableOperationOverride: TableOperationStatementProvider? on MainContentCoordinator (test-only seam, never assigned in production). FakeTableOperationProvider returns ANSI-style SQL. Result: SaveCompletionTests 13/13 green.

Verification

xcodebuild -project TablePro.xcodeproj -scheme TablePro test -skipPackagePluginValidation \
  -only-testing:TableProTests/SaveCompletionTests \
  -only-testing:TableProTests/CommandActionsDispatchTests \
  -only-testing:TableProTests/MainStatusBarLayoutTests \
  -only-testing:TableProTests/AnyChangeManagerTests \
  -only-testing:TableProTests/SQLStatementGeneratorTests

All 100% green except the 2 LIMIT-1 cases (see follow-ups). swiftlint --strict clean on all touched files.

Known pre-existing failures (NOT in this PR)

After the test target started compiling and the dialect fix landed, the full target run reports approximately 280 pre-existing failures previously masked by compile errors. These are out of scope; each warrants its own ticket. Buckets:

  • ~30 tests assert absent LIMIT 1 / TOP (1) / ALTER TABLE ... DELETE WHERE codegen. No such codegen exists in TablePro/Core/ChangeTracking/SQLStatementGenerator.swift. Either the safety-limit feature was removed and tests weren't deleted, or it was never implemented. Affected: SQLStatementGeneratorTests (2), SQLStatementGeneratorNoPKTests, SQLStatementGeneratorMSSQLTests, DataChangeManagerClickHouseTests.
  • ~80 tests crash with <external symbol> under parallel test execution. Tests touch DatabaseManager.shared / PluginManager.shared / global state and race when xcodebuild spawns multiple test host processes. Fix is either -parallel-testing-enabled NO or removing shared-state coupling. Affected: RowProviderSyncTests, SidebarFieldTests, JSONEditorHighlightTests, EvictionTests, BlobFormattingTests, ColumnTypeBadgeLabelTests, others.
  • ~5 outdated string/enum mappingsDatabaseTypeCassandraTests/scylladbIconName (scylladb-icon vs cassandra-icon), SafeModeLevelTests/iconNames (lock.open.fill vs lock.open), ConnectionURLFormatterTests MariaDB scheme, ConnectionSharingTests Private Key vs privateKey. Tests didn't track UI/serialization renames.
  • ~3 SSH path duplication bugsSSHConfigParserTests/testSSHTokensInIdentityFile, SSHConfigurationTests/testTildeExpansionWithSubpath. Real product bug: tilde expansion produces double-slashes ($HOME//.ssh/...).
  • ~30 test-logic / suspected-product bugsGroupStorageTests, EtcdQueryBuilderTests/emptyPrefix, DataChangeManagerExtendedTests/Full undo/redo chain. Need individual investigation per test.
  • ~10 MSSQL-plugin-not-loadedTableQueryBuilderMSSQLTests produces LIMIT 200 OFFSET 0 (PostgreSQL-style) instead of OFFSET ... FETCH NEXT. Plugin not registered in tests, so dialect lookup falls back to defaults.

I have not opened separate tickets for these — happy to do so if the team wants, but they would need product-owner triage first (especially bucket 1, where the right answer might be deleting the tests rather than building features).

Test plan

  • SaveCompletionTests — 13/13 green
  • CommandActionsDispatchTests — green
  • MainStatusBarLayoutTests — green
  • AnyChangeManagerTests — green
  • SQLStatementGeneratorTests — 49/51 green (2 LIMIT-1 are out-of-scope)
  • swiftlint --strict on all touched files — 0 violations
  • No production behavior change from the dialect fix (verified by inspection: existing callers all pass an explicit dialect from PluginManager.shared.sqlDialect(for:))

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