Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"lerna": "^8.2.3",
"prettier": "^3.0.2",
"rimraf": "4.4.1",
"supabase-test": "^0.0.11",
"supabase-test": "^0.0.14",
"ts-jest": "^29.4.5",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/hello-world/__tests__/hello-world.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const users = [
beforeAll(async () => {
({ pg, db, teardown } = await getConnections());

// insert users using pg PgTestClient to bypass RLS (supabase auth.users table is not granted access)
// insert users using pg PgTestClient to bypass RLS (required to insert into supabase auth.users)
user1 = await insertUser(pg, users[0].email, users[0].id);
user2 = await insertUser(pg, users[1].email, users[1].id);
user3 = await insertUser(pg, users[2].email, users[2].id);
Expand Down
24 changes: 10 additions & 14 deletions packages/hello-world/__tests__/seeding/seeding.csv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@ import path from 'path';
import { getConnections, PgTestClient, seed } from 'supabase-test';
import { users } from './data/seed-data';

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

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

beforeAll(async () => {
({ pg, db, teardown } = await getConnections(
{},
[
// load schema and it's dependencies (supabase full schema)
seed.launchql(),

// load from csv
seed.csv({
'auth.users': csv('users.csv'),
'rls_test.pets': csv('pets.csv')
})
]
));
({ pg, db, teardown } = await getConnections());

await pg.loadCsv({
'auth.users': csv('users.csv'),
'rls_test.pets': csv('pets.csv')
});

});

afterAll(async () => {
Expand Down
22 changes: 9 additions & 13 deletions packages/hello-world/__tests__/seeding/seeding.json.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import { getConnections, PgTestClient, seed } from 'supabase-test';
import { pets, users } from './data/seed-data';

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

beforeAll(async () => {
({ db, teardown } = await getConnections(
{},
[
// load schema and it's dependencies (supabase full schema)
seed.launchql(),

// load data from json files
seed.json({
'auth.users': users,
'rls_test.pets': pets
})
]
));
({ pg, db, teardown } = await getConnections());

await pg.loadJson({
'auth.users': users,
'rls_test.pets': pets
});
});

afterAll(async () => {
Expand Down
18 changes: 6 additions & 12 deletions packages/hello-world/__tests__/seeding/seeding.sql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@ import { getConnections, PgTestClient, seed } from 'supabase-test';
import path from 'path';
import { users } from './data/seed-data';

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

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

beforeAll(async () => {
({ db, teardown } = await getConnections(
{},
[
// load schema and it's dependencies (supabase full schema)
seed.launchql(),

// load data from sql file
seed.sqlfile([
sql('seed-data.sql'),
])
]
));
({ pg, db, teardown } = await getConnections());

await pg.loadSql([sql('seed-data.sql')]);
});

afterAll(async () => {
Expand Down
Loading