Skip to content

Commit 4c942a3

Browse files
Copilothotlong
andcommitted
feat: Add TCK compliance tests to all drivers
- Added TCK test files for Memory driver (reference implementation) - Added TCK test files for SQL driver (with SQLite in-memory) - Added TCK test files for MongoDB driver (with MongoMemoryReplSet) - Added TCK test files for Redis driver - Added TCK test files for Excel driver - Added TCK test files for FileSystem driver - Added TCK test files for LocalStorage driver (with mock) - Memory driver passes all 36 TCK tests Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 471effc commit 4c942a3

7 files changed

Lines changed: 421 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* ObjectQL Excel Driver TCK Tests
3+
* Copyright (c) 2026-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* Excel Driver TCK (Technology Compatibility Kit) Tests
11+
*
12+
* This test suite verifies that the Excel driver passes all TCK requirements.
13+
*/
14+
15+
import { runDriverTCK } from '@objectql/driver-tck';
16+
import { ExcelDriver } from '../src';
17+
import * as fs from 'fs';
18+
import * as path from 'path';
19+
20+
describe('ExcelDriver TCK Compliance', () => {
21+
const testFilePath = path.join(__dirname, 'tck-test.xlsx');
22+
let driver: ExcelDriver;
23+
24+
afterEach(() => {
25+
// Clean up test file
26+
if (fs.existsSync(testFilePath)) {
27+
fs.unlinkSync(testFilePath);
28+
}
29+
});
30+
31+
runDriverTCK(
32+
() => {
33+
driver = new ExcelDriver({
34+
filePath: testFilePath,
35+
autoSave: true
36+
});
37+
return driver;
38+
},
39+
{
40+
skip: {
41+
aggregations: true, // Excel driver doesn't support aggregations
42+
transactions: true, // Excel doesn't support transactions
43+
joins: true, // Excel doesn't support joins
44+
},
45+
timeout: 30000,
46+
hooks: {
47+
beforeEach: async () => {
48+
// Create fresh Excel file
49+
if (fs.existsSync(testFilePath)) {
50+
fs.unlinkSync(testFilePath);
51+
}
52+
},
53+
afterEach: async () => {
54+
// Cleanup handled in test afterEach
55+
}
56+
}
57+
}
58+
);
59+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* ObjectQL FileSystem Driver TCK Tests
3+
* Copyright (c) 2026-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* FileSystem Driver TCK (Technology Compatibility Kit) Tests
11+
*
12+
* This test suite verifies that the FS driver passes all TCK requirements.
13+
*/
14+
15+
import { runDriverTCK } from '@objectql/driver-tck';
16+
import { FileSystemDriver } from '../src';
17+
import * as fs from 'fs';
18+
import * as path from 'path';
19+
20+
describe('FileSystemDriver TCK Compliance', () => {
21+
const testDir = path.join(__dirname, 'tck-test-data');
22+
let driver: FileSystemDriver;
23+
24+
afterEach(() => {
25+
// Clean up test directory
26+
if (fs.existsSync(testDir)) {
27+
fs.rmSync(testDir, { recursive: true, force: true });
28+
}
29+
});
30+
31+
runDriverTCK(
32+
() => {
33+
driver = new FileSystemDriver({
34+
rootPath: testDir,
35+
format: 'json'
36+
});
37+
return driver;
38+
},
39+
{
40+
skip: {
41+
aggregations: true, // FS driver doesn't support aggregations
42+
transactions: true, // FS doesn't support transactions
43+
joins: true, // FS doesn't support joins
44+
},
45+
timeout: 30000,
46+
hooks: {
47+
beforeEach: async () => {
48+
// Create fresh directory
49+
if (fs.existsSync(testDir)) {
50+
fs.rmSync(testDir, { recursive: true, force: true });
51+
}
52+
fs.mkdirSync(testDir, { recursive: true });
53+
},
54+
afterEach: async () => {
55+
// Cleanup handled in test afterEach
56+
}
57+
}
58+
}
59+
);
60+
});
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* ObjectQL LocalStorage Driver TCK Tests
3+
* Copyright (c) 2026-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* LocalStorage Driver TCK (Technology Compatibility Kit) Tests
11+
*
12+
* This test suite verifies that the LocalStorage driver passes all TCK requirements.
13+
*/
14+
15+
import { runDriverTCK } from '@objectql/driver-tck';
16+
import { LocalStorageDriver } from '../src';
17+
18+
// Mock localStorage for Node.js environment
19+
class LocalStorageMock {
20+
private store: Map<string, string> = new Map();
21+
22+
getItem(key: string): string | null {
23+
return this.store.get(key) || null;
24+
}
25+
26+
setItem(key: string, value: string): void {
27+
this.store.set(key, value);
28+
}
29+
30+
removeItem(key: string): void {
31+
this.store.delete(key);
32+
}
33+
34+
clear(): void {
35+
this.store.clear();
36+
}
37+
38+
get length(): number {
39+
return this.store.size;
40+
}
41+
42+
key(index: number): string | null {
43+
const keys = Array.from(this.store.keys());
44+
return keys[index] || null;
45+
}
46+
}
47+
48+
describe('LocalStorageDriver TCK Compliance', () => {
49+
let driver: LocalStorageDriver;
50+
let mockStorage: LocalStorageMock;
51+
52+
runDriverTCK(
53+
() => {
54+
mockStorage = new LocalStorageMock();
55+
(global as any).localStorage = mockStorage;
56+
57+
driver = new LocalStorageDriver({
58+
namespace: 'tck_test'
59+
});
60+
return driver;
61+
},
62+
{
63+
skip: {
64+
aggregations: true, // LocalStorage driver doesn't support aggregations
65+
transactions: true, // LocalStorage doesn't support transactions
66+
joins: true, // LocalStorage doesn't support joins
67+
},
68+
timeout: 30000,
69+
hooks: {
70+
beforeEach: async () => {
71+
// Clear localStorage
72+
if (mockStorage) {
73+
mockStorage.clear();
74+
}
75+
},
76+
afterEach: async () => {
77+
// Cleanup handled in beforeEach
78+
}
79+
}
80+
}
81+
);
82+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* ObjectQL Memory Driver TCK Tests
3+
* Copyright (c) 2026-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* Memory Driver TCK (Technology Compatibility Kit) Tests
11+
*
12+
* This test suite verifies that the Memory driver passes all TCK requirements.
13+
* The Memory driver serves as the reference implementation for all ObjectQL drivers.
14+
*/
15+
16+
import { runDriverTCK } from '@objectql/driver-tck';
17+
import { MemoryDriver } from '../src';
18+
19+
describe('MemoryDriver TCK Compliance', () => {
20+
runDriverTCK(
21+
() => new MemoryDriver(),
22+
{
23+
// Memory driver supports all features
24+
skip: {
25+
// No features to skip - Memory driver is the reference implementation
26+
},
27+
timeout: 30000,
28+
hooks: {
29+
beforeEach: async () => {
30+
// No special setup needed
31+
},
32+
afterEach: async () => {
33+
// Cleanup handled by driver.clear() in TCK
34+
}
35+
}
36+
}
37+
);
38+
});
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* ObjectQL MongoDB Driver TCK Tests
3+
* Copyright (c) 2026-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* MongoDB Driver TCK (Technology Compatibility Kit) Tests
11+
*
12+
* This test suite verifies that the MongoDB driver passes all TCK requirements.
13+
*/
14+
15+
import { runDriverTCK } from '@objectql/driver-tck';
16+
import { MongoDriver } from '../src';
17+
import { MongoMemoryReplSet } from 'mongodb-memory-server';
18+
19+
describe('MongoDriver TCK Compliance', () => {
20+
let mongoServer: MongoMemoryReplSet;
21+
let driver: MongoDriver;
22+
23+
beforeAll(async () => {
24+
// Start MongoDB Memory Server with replica set (required for transactions)
25+
mongoServer = await MongoMemoryReplSet.create({
26+
replSet: { count: 1, storageEngine: 'wiredTiger' }
27+
});
28+
}, 120000);
29+
30+
afterAll(async () => {
31+
if (driver) {
32+
await driver.disconnect();
33+
}
34+
if (mongoServer) {
35+
await mongoServer.stop();
36+
}
37+
}, 60000);
38+
39+
runDriverTCK(
40+
() => {
41+
const uri = mongoServer.getUri();
42+
driver = new MongoDriver({
43+
url: uri,
44+
dbName: 'tck_test'
45+
});
46+
return driver;
47+
},
48+
{
49+
// MongoDB supports all features
50+
skip: {
51+
// No features to skip
52+
},
53+
timeout: 30000,
54+
hooks: {
55+
beforeEach: async () => {
56+
// Clear all collections
57+
if (driver && driver['db']) {
58+
const collections = await driver['db'].listCollections().toArray();
59+
for (const collection of collections) {
60+
await driver['db'].collection(collection.name).deleteMany({});
61+
}
62+
}
63+
},
64+
afterEach: async () => {
65+
// Cleanup handled in beforeEach
66+
}
67+
}
68+
}
69+
);
70+
});
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* ObjectQL Redis Driver TCK Tests
3+
* Copyright (c) 2026-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* Redis Driver TCK (Technology Compatibility Kit) Tests
11+
*
12+
* This test suite verifies that the Redis driver passes all TCK requirements.
13+
*/
14+
15+
import { runDriverTCK } from '@objectql/driver-tck';
16+
import { RedisDriver } from '../src';
17+
18+
describe('RedisDriver TCK Compliance', () => {
19+
let driver: RedisDriver;
20+
21+
runDriverTCK(
22+
() => {
23+
driver = new RedisDriver({
24+
host: process.env.REDIS_HOST || 'localhost',
25+
port: parseInt(process.env.REDIS_PORT || '6379'),
26+
db: 15 // Use a separate DB for testing
27+
});
28+
return driver;
29+
},
30+
{
31+
skip: {
32+
aggregations: true, // Redis driver doesn't support full aggregations
33+
joins: true, // Redis doesn't support joins
34+
},
35+
timeout: 30000,
36+
hooks: {
37+
beforeEach: async () => {
38+
// Clear the test database
39+
if (driver && driver['redis']) {
40+
await driver['redis'].flushdb();
41+
}
42+
},
43+
afterEach: async () => {
44+
// Cleanup handled in beforeEach
45+
}
46+
}
47+
}
48+
);
49+
});

0 commit comments

Comments
 (0)