Skip to content

A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.

C++

test(grid): scope refresh cache probe to active connection

Tobi41a6caeb456e
diff --git a/macos/Tests/GridexTests/DataGridRefreshTests.swift b/macos/Tests/GridexTests/DataGridRefreshTests.swift
index c739391..914b5af 100644
--- a/macos/Tests/GridexTests/DataGridRefreshTests.swift
+++ b/macos/Tests/GridexTests/DataGridRefreshTests.swift
@@ -148,6 +148,18 @@ final class DataGridRefreshTests: XCTestCase {
func test_reloadAfterStructureChange_discardsOlderLoadResultsAndMetadataCache() async throws {
let (grid, adapter) = try await makeCountingGrid()
DataGridViewState.clearMetadataCache()
+ let appState = AppState()
+ let config = ConnectionConfig(
+ name: "shared-refresh-cache-scope",
+ databaseType: .sqlite,
+ filePath: ":memory:"
+ )
+ appState.activeAdapter = adapter
+ appState.activeConnectionId = config.id
+ appState.activeConfig = config
+ appState.currentDatabaseName = "main"
+ grid.appState = appState
+ await grid.load(tableName: "scores", schema: nil, adapter: adapter)
let fetchGate = adapter.holdNextFetchAndCaptureTableDescription()
let olderLoad = Task { @MainActor in
@@ -169,6 +181,7 @@ final class DataGridRefreshTests: XCTestCase {
XCTAssertEqual(grid.tableDescription?.columns.map(\.name), ["record_id", "rank"])
let cacheProbe = DataGridViewState()
+ cacheProbe.appState = appState
await cacheProbe.load(tableName: "scores", schema: nil, adapter: adapter)
XCTAssertEqual(cacheProbe.primaryKeyColumns, ["record_id"])
XCTAssertEqual(cacheProbe.tableDescription?.columns.map(\.name), ["record_id", "rank"])