fix: fix cargo fmt and update tests for completion/snippet changes
- 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
This commit is contained in:
@@ -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<Mutex<duckdb::Connection>>) {
|
||||
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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user