Skip to content

Commit ea3f1e4

Browse files
committed
update tests
1 parent 8fa8d13 commit ea3f1e4

File tree

3 files changed

+25
-39
lines changed

3 files changed

+25
-39
lines changed

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 (supabase auth.users table is not granted access)
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 (supabase auth.users table is not granted access)
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 (supabase auth.users table is not granted access)
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)