test(embeddings): fix 6 remaining test failures
- Fix schema.test.ts: use Unix timestamp integers instead of Date objects for snippet_embeddings.createdAt - Fix embedding.service.test.ts: use 'local-default' profile instead of non-existent 'test-profile', remove require() calls and use proper ESM imports - Fix hybrid.search.service.test.ts: update VectorSearch.vectorSearch() calls to use options object instead of positional parameters, remove manual FTS insert (triggers handle it automatically) - Fix migration 0002: improve SQL formatting with line breaks after statement-breakpoint comments All 459 tests now passing (18 skipped).
This commit is contained in:
@@ -15,7 +15,8 @@ INSERT INTO embedding_profiles (id, provider_kind, title, enabled, is_default, m
|
||||
VALUES ('local-default', 'local-transformers', 'Local (Xenova/all-MiniLM-L6-v2)', 1, 1, 'Xenova/all-MiniLM-L6-v2', 384, '{}', unixepoch(), unixepoch())
|
||||
ON CONFLICT(id) DO NOTHING;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||
PRAGMA foreign_keys=OFF;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `__new_snippet_embeddings` (
|
||||
`snippet_id` text NOT NULL,
|
||||
`profile_id` text NOT NULL,
|
||||
@@ -28,7 +29,10 @@ CREATE TABLE `__new_snippet_embeddings` (
|
||||
FOREIGN KEY (`profile_id`) REFERENCES `embedding_profiles`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_snippet_embeddings`("snippet_id", "profile_id", "model", "dimensions", "embedding", "created_at") SELECT "snippet_id", 'local-default', "model", "dimensions", "embedding", "created_at" FROM `snippet_embeddings`;--> statement-breakpoint
|
||||
DROP TABLE `snippet_embeddings`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_snippet_embeddings` RENAME TO `snippet_embeddings`;--> statement-breakpoint
|
||||
INSERT INTO `__new_snippet_embeddings`("snippet_id", "profile_id", "model", "dimensions", "embedding", "created_at") SELECT "snippet_id", 'local-default', "model", "dimensions", "embedding", "created_at" FROM `snippet_embeddings`;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `snippet_embeddings`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `__new_snippet_embeddings` RENAME TO `snippet_embeddings`;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;
|
||||
@@ -39,6 +39,7 @@ function createTestDb() {
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const nowTimestamp = Math.floor(now.getTime() / 1000);
|
||||
|
||||
function makeRepo(overrides: Partial<schema.NewRepository> = {}): schema.NewRepository {
|
||||
return {
|
||||
@@ -300,10 +301,11 @@ describe('snippet_embeddings table', () => {
|
||||
db.insert(snippetEmbeddings)
|
||||
.values({
|
||||
snippetId,
|
||||
profileId: 'local-default',
|
||||
model: 'text-embedding-3-small',
|
||||
dimensions: 4,
|
||||
embedding: buf,
|
||||
createdAt: now
|
||||
createdAt: nowTimestamp
|
||||
})
|
||||
.run();
|
||||
|
||||
@@ -329,10 +331,11 @@ describe('snippet_embeddings table', () => {
|
||||
db.insert(snippetEmbeddings)
|
||||
.values({
|
||||
snippetId,
|
||||
profileId: 'local-default',
|
||||
model: 'test-model',
|
||||
dimensions: 2,
|
||||
embedding: Buffer.from(vec.buffer),
|
||||
createdAt: now
|
||||
createdAt: nowTimestamp
|
||||
})
|
||||
.run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user