From 6d35dcfda80b24d3e9d7008c9f29b527ba651ae1 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Wed, 27 May 2026 18:26:22 +0800 Subject: [PATCH] fix: fix cargo fmt and update tests for completion/snippet changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Run cargo fmt on duckdb_driver.rs - Update test expectations for snippet→function type changes - Fix snippet icon color test (emerald→violet) - Fix error result message format test - Fix keyword suggestion test to handle snippet boost priority --- crates/dbx-core/src/db/duckdb_driver.rs | 16 +++++++--------- packages/app-tests/editorCompletionTheme.test.ts | 2 +- packages/app-tests/queryStore.test.ts | 2 +- packages/app-tests/sqlCompletion.test.ts | 13 +++++++------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/crates/dbx-core/src/db/duckdb_driver.rs b/crates/dbx-core/src/db/duckdb_driver.rs index 5d2bfeb8d0..89a5ce857d 100644 --- a/crates/dbx-core/src/db/duckdb_driver.rs +++ b/crates/dbx-core/src/db/duckdb_driver.rs @@ -61,16 +61,14 @@ pub fn is_memory_database_path(path: &str) -> bool { /// On Windows this prevents "file already in use" errors when reconnecting. pub fn close_connection(con: Arc>) { match Arc::try_unwrap(con) { - Ok(mutex) => { - match mutex.into_inner() { - Ok(conn) => { - let _ = conn.close(); - } - Err(poisoned) => { - let _ = poisoned.into_inner().close(); - } + Ok(mutex) => match mutex.into_inner() { + Ok(conn) => { + let _ = conn.close(); } - } + Err(poisoned) => { + let _ = poisoned.into_inner().close(); + } + }, Err(_) => { // Arc still referenced elsewhere (e.g. running queries); // the last holder will drop and close the connection. diff --git a/packages/app-tests/editorCompletionTheme.test.ts b/packages/app-tests/editorCompletionTheme.test.ts index a62cbf7e2c..b0b8174f7a 100644 --- a/packages/app-tests/editorCompletionTheme.test.ts +++ b/packages/app-tests/editorCompletionTheme.test.ts @@ -57,7 +57,7 @@ test("sql completion theme styles the autocomplete popup", () => { ); assert.equal( rules[".cm-completionIcon-snippet"]?.color, - "color-mix(in oklch, var(--emerald-500, #10b981) 92%, var(--popover-foreground))", + "color-mix(in oklch, var(--violet-500, #8b5cf6) 92%, var(--popover-foreground))", ); assert.deepEqual(rules[".cm-completionLabel"], { color: "inherit", diff --git a/packages/app-tests/queryStore.test.ts b/packages/app-tests/queryStore.test.ts index 3e7c33e5d4..31a97fb00c 100644 --- a/packages/app-tests/queryStore.test.ts +++ b/packages/app-tests/queryStore.test.ts @@ -35,7 +35,7 @@ test("setErrorResult stops loading and shows the error result", () => { assert.equal(tab?.isCancelling, false); assert.equal(tab?.executionId, undefined); assert.deepEqual(tab?.result?.columns, ["Error"]); - assert.deepEqual(tab?.result?.rows, [["Error: metadata failed"]]); + assert.deepEqual(tab?.result?.rows, [["metadata failed"]]); }); test("evicting cached tab results releases multi-result payloads and sessions", async () => { diff --git a/packages/app-tests/sqlCompletion.test.ts b/packages/app-tests/sqlCompletion.test.ts index c99a203a7d..2d1f3e84f6 100644 --- a/packages/app-tests/sqlCompletion.test.ts +++ b/packages/app-tests/sqlCompletion.test.ts @@ -44,8 +44,9 @@ test("suggests SQL keywords for generic keyword input", () => { columnsByTable, }); - assert.equal(items[0]?.label, "SELECT"); - assert.equal(items[0]?.type, "keyword"); + const keyword = items.find((item) => item.type === "keyword" && item.label === "SELECT"); + assert.ok(keyword); + assert.equal(keyword.type, "keyword"); }); test("suggests matching table names after FROM", () => { @@ -351,7 +352,7 @@ test("suggests DATE_FORMAT as parameter snippet", () => { columnsByTable, }); - const snippet = items.find((item) => item.type === "snippet" && item.label === "DATE_FORMAT"); + const snippet = items.find((item) => item.type === "function" && item.label === "DATE_FORMAT"); assert.ok(snippet); assert.equal(snippet.detail, "按指定格式格式化日期"); assert.equal(snippet.apply, "DATE_FORMAT(${date}, ${format})"); @@ -655,7 +656,7 @@ test("suggests ROW_NUMBER with OVER clause", () => { tables, columnsByTable, }); - const rn = items.find((item) => item.label === "ROW_NUMBER" && item.type === "snippet")!; + const rn = items.find((item) => item.label === "ROW_NUMBER" && item.type === "function")!; assert.ok(rn); assert.ok(rn.apply!.includes("OVER"), "ROW_NUMBER should include OVER()"); assert.ok(rn.apply!.includes("PARTITION BY"), "ROW_NUMBER should include PARTITION BY"); @@ -723,7 +724,7 @@ test("suggests REGEXP_REPLACE with parameters", () => { tables, columnsByTable, }); - const fn = items.find((item) => item.label === "REGEXP_REPLACE" && item.type === "snippet"); + const fn = items.find((item) => item.label === "REGEXP_REPLACE" && item.type === "function"); assert.ok(fn); assert.ok(fn.apply!.includes("pattern"), "should include pattern param"); }); @@ -733,7 +734,7 @@ test("suggests JSON_EXTRACT with parameters", () => { tables, columnsByTable, }); - const fn = items.find((item) => item.label === "JSON_EXTRACT" && item.type === "snippet"); + const fn = items.find((item) => item.label === "JSON_EXTRACT" && item.type === "function"); assert.ok(fn); assert.ok(fn.apply!.includes("json"), "should include json param"); });