Skip to content

Commit 3b35975

Browse files
committed
sqlite in memory
1 parent 0088e06 commit 3b35975

1 file changed

Lines changed: 19 additions & 34 deletions

File tree

tests/all-queues.test.ts

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -101,40 +101,25 @@ const drivers: Array<() => Promise<QueueDriverConfig> | QueueDriverConfig> = [
101101
},
102102
};
103103
},
104-
() => {
105-
let tempDbFile: string;
106-
107-
return {
108-
name: "SQLiteQueue",
109-
features: {
110-
supportsPriority: true, // SQLite supports priority ordering
111-
supportsDelayedJobs: true,
112-
supportsStatus: true,
113-
},
114-
beforeAll: async () => {
115-
// Create temporary SQLite database file
116-
tempDbFile = path.join(
117-
os.tmpdir(),
118-
`sqlite-queue-test-${Date.now()}.db`
119-
);
120-
},
121-
afterAll: async () => {
122-
// Clean up SQLite database file
123-
try {
124-
await fs.unlink(tempDbFile).catch(() => {});
125-
} catch (error) {
126-
console.warn("Failed to clean up SQLite database file:", error);
127-
}
128-
},
129-
createQueue: async () => {
130-
// Create new SQLite queue for each test
131-
return createSQLiteQueue<TestJobs>("test-queue", tempDbFile);
132-
},
133-
cleanup: async () => {
134-
await fs.unlink(tempDbFile);
135-
},
136-
};
137-
},
104+
() => ({
105+
name: "SQLiteQueue",
106+
features: {
107+
supportsPriority: true, // SQLite supports priority ordering
108+
supportsDelayedJobs: true,
109+
supportsStatus: true,
110+
},
111+
createQueue: async () => {
112+
// Use in-memory SQLite database for tests - much faster and no file cleanup needed
113+
return createSQLiteQueue<TestJobs>("test-queue", ":memory:");
114+
},
115+
cleanup: async (queue) => {
116+
// Clear all jobs from the in-memory database
117+
const adapter = (queue as any).db;
118+
if (adapter && typeof adapter.clear === 'function') {
119+
await adapter.clear();
120+
}
121+
},
122+
}),
138123
async () => {
139124
let redisContainer: StartedTestContainer;
140125
let redisClient: RedisClientType;

0 commit comments

Comments
 (0)