|
1 | | -import { describe, expect, test } from "bun:test" |
| 1 | +import { afterEach, describe, expect, spyOn, test } from "bun:test" |
2 | 2 | import { writeFileSync } from "node:fs" |
3 | 3 | import path from "node:path" |
4 | 4 | import { createDispatcherRunner } from "../../src/altimate/review/runner" |
| 5 | +import { Dispatcher } from "../../src/altimate/native" |
5 | 6 | import { tmpdir } from "../fixture/fixture" |
6 | 7 |
|
| 8 | +let dispatcherSpy: ReturnType<typeof spyOn> | undefined |
| 9 | + |
| 10 | +afterEach(() => { |
| 11 | + dispatcherSpy?.mockRestore() |
| 12 | + dispatcherSpy = undefined |
| 13 | +}) |
| 14 | + |
7 | 15 | describe("review manifest loading", () => { |
8 | 16 | test("loads a valid manifest without initializing the native dispatcher", async () => { |
9 | 17 | await using tmp = await tmpdir() |
@@ -36,4 +44,47 @@ describe("review manifest loading", () => { |
36 | 44 | testCount: 0, |
37 | 45 | }) |
38 | 46 | }) |
| 47 | + |
| 48 | + test("threads adapter dialect into core equivalence", async () => { |
| 49 | + await using tmp = await tmpdir() |
| 50 | + const manifestPath = path.join(tmp.path, "manifest.json") |
| 51 | + writeFileSync( |
| 52 | + manifestPath, |
| 53 | + JSON.stringify({ |
| 54 | + metadata: { adapter_type: "duckdb" }, |
| 55 | + nodes: { |
| 56 | + "model.demo.orders": { |
| 57 | + resource_type: "model", |
| 58 | + name: "orders", |
| 59 | + original_file_path: "models/orders.sql", |
| 60 | + config: { materialized: "table" }, |
| 61 | + depends_on: { nodes: [] }, |
| 62 | + columns: { id: { name: "id", data_type: "integer" } }, |
| 63 | + }, |
| 64 | + }, |
| 65 | + sources: {}, |
| 66 | + }), |
| 67 | + ) |
| 68 | + |
| 69 | + let seenParams: any |
| 70 | + dispatcherSpy = spyOn(Dispatcher, "call").mockImplementation((async (method: string, params: any) => { |
| 71 | + expect(method).toBe("altimate_core.equivalence") |
| 72 | + seenParams = params |
| 73 | + return { |
| 74 | + success: true, |
| 75 | + data: { |
| 76 | + equivalent: true, |
| 77 | + confidence: 0.95, |
| 78 | + differences: [], |
| 79 | + validation_errors: [], |
| 80 | + }, |
| 81 | + } |
| 82 | + }) as any) |
| 83 | + |
| 84 | + const runner = createDispatcherRunner({ manifestPath }) |
| 85 | + const result = await runner.equivalence("select id from orders", "select id from orders", "duckdb") |
| 86 | + |
| 87 | + expect(result).toEqual({ decided: true, equivalent: true, differences: [], confidence: "high" }) |
| 88 | + expect(seenParams.dialect).toBe("duckdb") |
| 89 | + }) |
39 | 90 | }) |
0 commit comments