Skip to content

Commit df98b15

Browse files
committed
sea-execution: refresh test fakes for the merged-kernel binding surface
Rebased onto the fixed sea-auth (#379 review fixes). Updates the unit-test fakes to the merged-kernel Connection/Statement surface so the spec type-checks under ts-node: - FakeNativeStatement: add statementId + the status accessors (numModifiedRows/displayMessage/diagnosticInfo/errorDetailsJson) and make schema() synchronous. - FakeNativeConnection: add the sessionId getter; make executeStatement's options param optional so it stays assignable to the binding's executeStatement(sql) while still recording forwarded options. - makeBinding: cast Connection/Statement through the binding's member types (typeof is illegal on the loader's type aliases). - e2e: cast useSEA as ConnectionOptions & InternalConnectionOptions (the e2e test now lives under the wired tests/e2e/sea/ dir). Note: the SeaOperationBackend status()/getResultMetadata() neutral-type conformance and the per-statement-options -> session-level migration remain pre-existing follow-ups for sea-results (tracked on the stack tip). Co-authored-by: Isaac
1 parent d57093d commit df98b15

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

tests/e2e/sea/execution-e2e.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import { expect } from 'chai';
1616
import { DBSQLClient } from '../../../lib';
17+
import { ConnectionOptions } from '../../../lib/contracts/IDBSQLClient';
18+
import { InternalConnectionOptions } from '../../../lib/contracts/InternalConnectionOptions';
1719

1820
/**
1921
* sea-execution end-to-end test.
@@ -66,7 +68,7 @@ describe('SEA execution end-to-end', function e2eSuite() {
6668
path: httpPath as string,
6769
token: token as string,
6870
useSEA: true,
69-
});
71+
} as ConnectionOptions & InternalConnectionOptions);
7072

7173
const session = await client.openSession({
7274
initialCatalog: 'main',
@@ -99,7 +101,7 @@ describe('SEA execution end-to-end', function e2eSuite() {
99101
path: httpPath as string,
100102
token: token as string,
101103
useSEA: true,
102-
});
104+
} as ConnectionOptions & InternalConnectionOptions);
103105

104106
// Sanity-check that supplying session-level Spark conf does not
105107
// break openSession. The SEA wire applies these as `parameters` on

tests/unit/sea/execution.test.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ class FakeNativeStatement implements SeaNativeStatement {
3939

4040
public cancelled = false;
4141

42+
// Mirrors the kernel `Statement.statementId` getter.
43+
public readonly statementId = '01ef-fake-statement-id';
44+
4245
public async fetchNextBatch() {
4346
return null;
4447
}
4548

46-
public async schema() {
49+
// schema() is synchronous on the merged-kernel binding.
50+
public schema() {
4751
return { ipcBytes: Buffer.alloc(0) };
4852
}
4953

@@ -54,6 +58,23 @@ class FakeNativeStatement implements SeaNativeStatement {
5458
public async close() {
5559
this.closed = true;
5660
}
61+
62+
// Status accessors added by the kernel's status-fields surface.
63+
public async numModifiedRows(): Promise<number | null> {
64+
return null;
65+
}
66+
67+
public async displayMessage(): Promise<string | null> {
68+
return null;
69+
}
70+
71+
public async diagnosticInfo(): Promise<string | null> {
72+
return null;
73+
}
74+
75+
public async errorDetailsJson(): Promise<string | null> {
76+
return null;
77+
}
5778
}
5879

5980
class FakeNativeConnection implements SeaNativeConnection {
@@ -67,7 +88,14 @@ class FakeNativeConnection implements SeaNativeConnection {
6788

6889
public statementToReturn: FakeNativeStatement = new FakeNativeStatement();
6990

70-
public async executeStatement(sql: string, options: SeaExecuteOptions): Promise<SeaNativeStatement> {
91+
// Mirrors the kernel `Connection.sessionId` getter.
92+
public readonly sessionId = '01ef-fake-session-id';
93+
94+
// `options` is optional so this stays structurally assignable to the
95+
// merged binding's `executeStatement(sql)` while still recording any
96+
// per-statement options the caller forwards (the kernel now applies
97+
// those at session level — see the session-level options migration).
98+
public async executeStatement(sql: string, options?: SeaExecuteOptions): Promise<SeaNativeStatement> {
7199
if (this.throwOnExecute) {
72100
throw this.throwOnExecute;
73101
}
@@ -88,8 +116,10 @@ function makeBinding(connection: SeaNativeConnection): SeaNativeBinding & {
88116
const binding: SeaNativeBinding = {
89117
version: () => 'test',
90118
openSession: openSessionStub,
91-
Connection: function Connection() {},
92-
Statement: function Statement() {},
119+
// Index the binding type for the class constructor types; `typeof
120+
// Connection` is illegal since they're exported as type aliases.
121+
Connection: function Connection() {} as unknown as SeaNativeBinding['Connection'],
122+
Statement: function Statement() {} as unknown as SeaNativeBinding['Statement'],
93123
};
94124
return Object.assign(binding, { openSessionStub });
95125
}

0 commit comments

Comments
 (0)