refactor(desktop): organize lib modules by domain
This commit is contained in:
1 parent
90f0594e93
commit
7e7c4944e9
700 files changed
+1292
-1264
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { QueryResult } from "@/types/database";
|
||||
|
||||
import { isNoSnapshotErrorResult } from "@/lib/query/queryResultError";
|
||||
|
||||
function errorResult(message: string): QueryResult {
|
||||
return { columns: ["Error"], rows: [[message]], affected_rows: 0, execution_time_ms: 0 };
|
||||
}
|
||||
|
||||
function dataResult(columns: string[]): QueryResult {
|
||||
return { columns, rows: [], affected_rows: 0, execution_time_ms: 0 };
|
||||
}
|
||||
|
||||
describe("isNoSnapshotErrorResult", () => {
|
||||
it("matches the StarRocks Paimon no-snapshot error surfaced via executeTabSql", () => {
|
||||
const result = errorResult("Server error: `ERROR HY000 (1064): There is currently no snapshot.`");
|
||||
expect(isNoSnapshotErrorResult(result)).toBe(true);
|
||||
});
|
||||
|
||||
it("matches case-insensitively", () => {
|
||||
const result = errorResult("there IS currently NO snapshot");
|
||||
expect(isNoSnapshotErrorResult(result)).toBe(true);
|
||||
});
|
||||
|
||||
it("does not match unrelated query errors", () => {
|
||||
expect(isNoSnapshotErrorResult(errorResult("Unknown table 'tag_test.record_tag_t'"))).toBe(false);
|
||||
expect(isNoSnapshotErrorResult(errorResult("ERROR 1142: SELECT command denied"))).toBe(false);
|
||||
});
|
||||
|
||||
it("does not match successful data results", () => {
|
||||
expect(isNoSnapshotErrorResult(dataResult(["id", "name"]))).toBe(false);
|
||||
expect(isNoSnapshotErrorResult(dataResult(["Error"]))).toBe(false); // data column literally named Error, no rows
|
||||
});
|
||||
|
||||
it("returns false for missing or empty results", () => {
|
||||
expect(isNoSnapshotErrorResult(undefined)).toBe(false);
|
||||
expect(isNoSnapshotErrorResult(null)).toBe(false);
|
||||
expect(isNoSnapshotErrorResult({ ...errorResult("There is currently no snapshot."), rows: [] })).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user