Skip to content

Commit

Permalink
Disable tokenizer tests for libsql
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Nov 18, 2024
1 parent 8675ec3 commit 109541f
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions example/src/tests/tokenizer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {open, type DB} from '@op-engineering/op-sqlite';
import {isLibsql, open, type DB} from '@op-engineering/op-sqlite';
import chai from 'chai';
import {afterEach, beforeEach, describe, it} from './MochaRNAdapter';

Expand All @@ -14,9 +14,11 @@ export function tokenizerTests() {
encryptionKey: 'test',
});

await db.execute(
`CREATE VIRTUAL TABLE tokenizer_table USING fts5(content, tokenize = 'wordtokenizer');`,
);
if (!isLibsql()) {
await db.execute(
`CREATE VIRTUAL TABLE tokenizer_table USING fts5(content, tokenize = 'wordtokenizer');`,
);
}
});

afterEach(() => {
Expand All @@ -28,16 +30,18 @@ export function tokenizerTests() {
}
});

it('Should match the word split by the tokenizer', async () => {
await db.execute('INSERT INTO tokenizer_table(content) VALUES (?)', [
'This is a test document',
]);
const res = await db.execute(
'SELECT content FROM tokenizer_table WHERE content MATCH ?',
['test'],
);
expect(res.rows.length).to.be.equal(1);
expect(res.rows[0]!.content).to.be.equal('This is a test document');
});
if (!isLibsql()) {
it('Should match the word split by the tokenizer', async () => {
await db.execute('INSERT INTO tokenizer_table(content) VALUES (?)', [
'This is a test document',
]);
const res = await db.execute(
'SELECT content FROM tokenizer_table WHERE content MATCH ?',
['test'],
);
expect(res.rows.length).to.be.equal(1);
expect(res.rows[0]!.content).to.be.equal('This is a test document');
});
}
});
}

0 comments on commit 109541f

Please sign in to comment.