1 parent
7c8e0a88cf
commit
e7ef9df85c
4 files changed
+123
-51
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isSameTransferDatabase, normalizeTransferCatalog, type TransferDatabaseSelection } from "@/lib/database/dataTransferSelection";
|
||||
import { decodeTransferDatabaseOption, encodeTransferDatabaseOptions, isSameTransferDatabase, isTransferDatabaseSelected, normalizeTransferCatalog, type TransferDatabaseSelection } from "@/lib/database/dataTransferSelection";
|
||||
import { TREE_SCHEMA_DEFAULT_DATABASE_SELECT_VALUE } from "@/lib/database/defaultDatabase";
|
||||
import type { CatalogInfo } from "@/types/database";
|
||||
|
||||
function catalog(name: string, catalog_type: string): CatalogInfo {
|
||||
@@ -17,6 +18,27 @@ function selection(overrides: Partial<TransferDatabaseSelection> = {}): Transfer
|
||||
}
|
||||
|
||||
describe("data transfer database selection", () => {
|
||||
it("keeps a Kingbase default database distinct from no selection", () => {
|
||||
const options = encodeTransferDatabaseOptions("kingbase", [""]);
|
||||
|
||||
expect(options).toEqual([TREE_SCHEMA_DEFAULT_DATABASE_SELECT_VALUE]);
|
||||
expect(isTransferDatabaseSelected(options[0])).toBe(true);
|
||||
expect(isTransferDatabaseSelected("")).toBe(false);
|
||||
expect(decodeTransferDatabaseOption("kingbase", options[0])).toBe("");
|
||||
});
|
||||
|
||||
it("uses the tree-schema default database contract for PostgreSQL", () => {
|
||||
const [option] = encodeTransferDatabaseOptions("postgres", [""]);
|
||||
|
||||
expect(option).toBe(TREE_SCHEMA_DEFAULT_DATABASE_SELECT_VALUE);
|
||||
expect(decodeTransferDatabaseOption("postgres", option)).toBe("");
|
||||
});
|
||||
|
||||
it.each(["kingbase", "dameng", "mysql", "mongodb", "starrocks"] as const)("preserves named %s databases", (databaseType) => {
|
||||
expect(encodeTransferDatabaseOptions(databaseType, ["app", "analytics"])).toEqual(["app", "analytics"]);
|
||||
expect(decodeTransferDatabaseOption(databaseType, "analytics")).toBe("analytics");
|
||||
});
|
||||
|
||||
it("normalizes empty, Doris internal, and StarRocks default catalogs", () => {
|
||||
expect(normalizeTransferCatalog("", [])).toBe("");
|
||||
expect(normalizeTransferCatalog("internal", [])).toBe("");
|
||||
|
||||
Reference in new issue
Block a user