Initial Commit
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Integration test — `detectVersion` against the live SurrealDB v3.0.4 fixture.
|
||||
*
|
||||
* Spec: openspec/changes/surrealdb-integration-tests — Requirement
|
||||
* "Version detector verified against the real engine":
|
||||
* WHEN the version detector runs against the started fixture
|
||||
* THEN the parsed major is `3`.
|
||||
*
|
||||
* `detectVersion` accepts a `SurrealClientLike`; the adapter holds it as a
|
||||
* protected `_client`. We subclass `SurrealAdapter` and expose a typed getter
|
||||
* so the test can hand the live client to the detector without `as`-casts
|
||||
* into private state.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import { SurrealAdapter } from "../../src/adapter/adapter/adapter.js";
|
||||
import type { SurrealClientLike } from "../../src/types/index.js";
|
||||
import { detectVersion } from "../../src/utils/version-detector.js";
|
||||
import { inject, surrealUnavailable } from "./integration-setup.js";
|
||||
|
||||
class ClientExposingAdapter extends SurrealAdapter {
|
||||
public get client(): SurrealClientLike {
|
||||
if (this._client === null) {
|
||||
throw new Error(
|
||||
"ClientExposingAdapter.client read before connect()"
|
||||
);
|
||||
}
|
||||
return this._client;
|
||||
}
|
||||
}
|
||||
|
||||
async function connectExposed(): Promise<ClientExposingAdapter> {
|
||||
const config = inject("surrealdb");
|
||||
const adapter = new ClientExposingAdapter({
|
||||
url: config.url,
|
||||
namespace: config.namespace,
|
||||
database: config.database,
|
||||
username: config.username,
|
||||
password: config.password,
|
||||
});
|
||||
await adapter.connect();
|
||||
return adapter;
|
||||
}
|
||||
|
||||
describe.skipIf(surrealUnavailable)(
|
||||
"SurrealDB version detector (real SurrealDB v3.0.4)",
|
||||
() => {
|
||||
it("returns a non-empty version string from the live server", {
|
||||
timeout: 30000,
|
||||
}, async () => {
|
||||
const adapter = await connectExposed();
|
||||
try {
|
||||
const info = await detectVersion(adapter.client);
|
||||
expect(typeof info.version).toBe("string");
|
||||
expect(info.version.length).toBeGreaterThan(0);
|
||||
} finally {
|
||||
await adapter.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
it("parsed major version equals 3 (matches pinned image surrealdb:v3.0.4)", {
|
||||
timeout: 30000,
|
||||
}, async () => {
|
||||
const adapter = await connectExposed();
|
||||
try {
|
||||
const info = await detectVersion(adapter.client);
|
||||
expect(info.major).toBe(3);
|
||||
} finally {
|
||||
await adapter.disconnect();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user