Skip to content

Commit

Permalink
Improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jul 14, 2024
1 parent 90765e5 commit e76ed76
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/drizzle-orm/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { pgTable, serial, vector, halfvec, bit, sparsevec } from 'drizzle-orm/pg
import { SparseVector } from 'pgvector';
import postgres from 'postgres';

test('example', async () => {
test('drizzle-orm example', async () => {
const client = postgres({database: 'pgvector_node_test', onnotice: function () { }});
const db = drizzle(client);

Expand Down
2 changes: 1 addition & 1 deletion tests/knex/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Knex from 'knex';
import pgvector from 'pgvector/knex';
import { SparseVector } from 'pgvector';

test('example', async () => {
test('knex example', async () => {
const knex = Knex({
client: 'pg',
connection: {database: 'pgvector_node_test'}
Expand Down
2 changes: 1 addition & 1 deletion tests/kysely/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import pgvector from 'pgvector/kysely';
import { l2Distance, maxInnerProduct, cosineDistance, l1Distance, hammingDistance, jaccardDistance } from 'pgvector/kysely';
import { SparseVector } from 'pgvector';

test('example', async () => {
test('kysely example', async () => {
const dialect = new PostgresDialect({
pool: new pg.Pool({
database: 'pgvector_node_test'
Expand Down
5 changes: 3 additions & 2 deletions tests/mikro-orm/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MikroORM, EntityManager, EntitySchema } from '@mikro-orm/postgresql';
import { VectorType, HalfvecType, BitType, SparsevecType, l2Distance, maxInnerProduct, cosineDistance, l1Distance, hammingDistance, jaccardDistance } from 'pgvector/mikro-orm';
import { SparseVector } from 'pgvector';

test('example', async () => {
test('mikro-orm example', async () => {
const Item = new EntitySchema({
name: 'Item',
tableName: 'mikro_items',
Expand All @@ -25,9 +25,10 @@ test('example', async () => {
const em = orm.em.fork();

await em.execute('CREATE EXTENSION IF NOT EXISTS vector');
await em.execute('DROP TABLE IF EXISTS mikro_items');

const generator = orm.getSchemaGenerator();
await generator.refreshDatabase();
await generator.createSchema();

em.create(Item, {embedding: [1, 1, 1], half_embedding: [1, 1, 1], binary_embedding: '000', sparse_embedding: new SparseVector([1, 1, 1])});
em.create(Item, {embedding: [2, 2, 2], half_embedding: [2, 2, 2], binary_embedding: '101', sparse_embedding: new SparseVector([2, 2, 2])});
Expand Down
2 changes: 1 addition & 1 deletion tests/objection/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import pgvector from 'pgvector/objection';
import { l2Distance, maxInnerProduct, cosineDistance, l1Distance, hammingDistance, jaccardDistance } from 'pgvector/objection';
import { SparseVector } from 'pgvector';

test('example', async () => {
test('objection example', async () => {
const knex = Knex({
client: 'pg',
connection: {database: 'pgvector_node_test'}
Expand Down
2 changes: 1 addition & 1 deletion tests/pg-promise/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import pgpromise from 'pg-promise';
import pgvector from 'pgvector/pg-promise';
import { SparseVector } from 'pgvector';

test('example', async () => {
test('pg-promise example', async () => {
const initOptions = {
async connect(e) {
await pgvector.registerTypes(e.client);
Expand Down
2 changes: 1 addition & 1 deletion tests/pg/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import pg from 'pg';
import pgvector from 'pgvector/pg';
import { SparseVector } from 'pgvector';

test('example', async () => {
test('pg example', async () => {
const client = new pg.Client({database: 'pgvector_node_test'});
await client.connect();

Expand Down
2 changes: 1 addition & 1 deletion tests/postgres/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import postgres from 'postgres';
import pgvector from 'pgvector';
import { SparseVector } from 'pgvector';

test('example', async () => {
test('postgres example', async () => {
const sql = postgres({database: 'pgvector_node_test', onnotice: function () { }});

await sql`CREATE EXTENSION IF NOT EXISTS vector`;
Expand Down
2 changes: 1 addition & 1 deletion tests/sequelize/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import pgvector from 'pgvector/sequelize';
import { l2Distance, maxInnerProduct, cosineDistance, l1Distance, hammingDistance, jaccardDistance } from 'pgvector/sequelize';
import { SparseVector } from 'pgvector';

test('example', async () => {
test('sequelize example', async () => {
pgvector.registerTypes(Sequelize);

let sequelize = new Sequelize('postgres://localhost/pgvector_node_test', {
Expand Down
2 changes: 1 addition & 1 deletion tests/slonik/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import pgvector from 'pgvector';
import { SparseVector } from 'pgvector';
import { createPool, sql } from 'slonik';

test('example', async () => {
test('slonik example', async () => {
const pool = await createPool('postgres://localhost/pgvector_node_test');

await pool.query(sql.unsafe`CREATE EXTENSION IF NOT EXISTS vector`);
Expand Down
2 changes: 1 addition & 1 deletion tests/typeorm/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import pgvector from 'pgvector';
import { SparseVector } from 'pgvector';
import { DataSource, EntitySchema } from 'typeorm';

test('example', async () => {
test('typeorm example', async () => {
// entity definition without decorators
// https://typeorm.io/separating-entity-definition
const Item = new EntitySchema({
Expand Down

0 comments on commit e76ed76

Please sign in to comment.