diff --git a/database.json b/database.json index dd69290..a2bf251 100644 --- a/database.json +++ b/database.json @@ -9,7 +9,7 @@ "test": { "driver": "pg", "host": "127.0.0.1", - "database": "shelf-test", + "database": "shelf_test", "user": "postgres", "password": "fredy123" } diff --git a/src/models/product.ts b/src/models/product.ts index a963769..6916fd3 100644 --- a/src/models/product.ts +++ b/src/models/product.ts @@ -60,7 +60,7 @@ export class ProductStore { try { const conn = await client.connect(); const result = await conn.query( - 'UPDATE products SET name=$1, price=$2 WHERE id=$3 returning *;', + 'UPDATE products SET name=$1, price=$2 WHERE id=$3 RETURNING *;', [p.name, p.price, p.id] ); conn.release() @@ -72,7 +72,7 @@ export class ProductStore { async delete(id: number): Promise { try { - const sql = 'DELETE FROM products WHERE id=(1$)' + const sql = 'DELETE FROM products WHERE id=($1)' // @ts-ignore const conn = await client.connect() diff --git a/src/models/tests/product_spec.ts b/src/models/tests/product_spec.ts index 98db413..b6f7105 100644 --- a/src/models/tests/product_spec.ts +++ b/src/models/tests/product_spec.ts @@ -33,7 +33,7 @@ describe("Products store Model", () => { }); }); - /*it('index method should return a list of products', async () => { + it('index method should return a list of products', async () => { const result = await store.index(); expect(result).toEqual([{ id: 1, @@ -57,6 +57,6 @@ describe("Products store Model", () => { const result = await store.index() expect(result).toEqual([]); - });*/ + }); });