Skip to content

Commit e7528e4

Browse files
authored
Merge pull request #19 from launchql/feat/upgrade-014
2 parents be0a3e0 + c4cdf0e commit e7528e4

File tree

6 files changed

+1748
-105
lines changed

6 files changed

+1748
-105
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"lerna": "^8.2.3",
4141
"prettier": "^3.0.2",
4242
"rimraf": "4.4.1",
43-
"supabase-test": "^0.0.11",
43+
"supabase-test": "^0.0.14",
4444
"ts-jest": "^29.4.5",
4545
"ts-node": "^10.9.2",
4646
"typescript": "^5.9.3"

packages/hello-world/__tests__/hello-world.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const users = [
2626
beforeAll(async () => {
2727
({ pg, db, teardown } = await getConnections());
2828

29-
// insert users using pg PgTestClient to bypass RLS (supabase auth.users table is not granted access)
29+
// insert users using pg PgTestClient to bypass RLS (required to insert into supabase auth.users)
3030
user1 = await insertUser(pg, users[0].email, users[0].id);
3131
user2 = await insertUser(pg, users[1].email, users[1].id);
3232
user3 = await insertUser(pg, users[2].email, users[2].id);

packages/hello-world/__tests__/seeding/seeding.csv.test.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,22 @@ import path from 'path';
22
import { getConnections, PgTestClient, seed } from 'supabase-test';
33
import { users } from './data/seed-data';
44

5-
let pg: PgTestClient;
5+
// pg is used to have RLS bypass (required to insert into supabase auth.users)
66
let db: PgTestClient;
7+
// db is used to test the RLS policies in test cases
8+
let pg: PgTestClient;
79
let teardown: () => Promise<void>;
810

911
const csv = (file: string) => path.resolve(__dirname, './data', file);
1012

1113
beforeAll(async () => {
12-
({ pg, db, teardown } = await getConnections(
13-
{},
14-
[
15-
// load schema and it's dependencies (supabase full schema)
16-
seed.launchql(),
17-
18-
// load from csv
19-
seed.csv({
20-
'auth.users': csv('users.csv'),
21-
'rls_test.pets': csv('pets.csv')
22-
})
23-
]
24-
));
14+
({ pg, db, teardown } = await getConnections());
15+
16+
await pg.loadCsv({
17+
'auth.users': csv('users.csv'),
18+
'rls_test.pets': csv('pets.csv')
19+
});
20+
2521
});
2622

2723
afterAll(async () => {

packages/hello-world/__tests__/seeding/seeding.json.test.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
import { getConnections, PgTestClient, seed } from 'supabase-test';
22
import { pets, users } from './data/seed-data';
33

4+
// pg is used to have RLS bypass (required to insert into supabase auth.users)
45
let db: PgTestClient;
6+
// db is used to test the RLS policies in test cases
7+
let pg: PgTestClient;
58
let teardown: () => Promise<void>;
69

710
beforeAll(async () => {
8-
({ db, teardown } = await getConnections(
9-
{},
10-
[
11-
// load schema and it's dependencies (supabase full schema)
12-
seed.launchql(),
13-
14-
// load data from json files
15-
seed.json({
16-
'auth.users': users,
17-
'rls_test.pets': pets
18-
})
19-
]
20-
));
11+
({ pg, db, teardown } = await getConnections());
12+
13+
await pg.loadJson({
14+
'auth.users': users,
15+
'rls_test.pets': pets
16+
});
2117
});
2218

2319
afterAll(async () => {

packages/hello-world/__tests__/seeding/seeding.sql.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,18 @@ import { getConnections, PgTestClient, seed } from 'supabase-test';
22
import path from 'path';
33
import { users } from './data/seed-data';
44

5+
// pg is used to have RLS bypass (required to insert into supabase auth.users)
56
let db: PgTestClient;
7+
// db is used to test the RLS policies in test cases
8+
let pg: PgTestClient;
69
let teardown: () => Promise<void>;
710

811
const sql = (f: string) => path.join(__dirname, 'data', f);
912

1013
beforeAll(async () => {
11-
({ db, teardown } = await getConnections(
12-
{},
13-
[
14-
// load schema and it's dependencies (supabase full schema)
15-
seed.launchql(),
16-
17-
// load data from sql file
18-
seed.sqlfile([
19-
sql('seed-data.sql'),
20-
])
21-
]
22-
));
14+
({ pg, db, teardown } = await getConnections());
15+
16+
await pg.loadSql([sql('seed-data.sql')]);
2317
});
2418

2519
afterAll(async () => {

0 commit comments

Comments
 (0)