mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
ref: remove unused code
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import { createClient, SupabaseClient } from "@supabase/supabase-js";
|
||||
import { faker } from "@faker-js/faker";
|
||||
|
||||
export type TestUser = {
|
||||
email: string;
|
||||
@@ -26,24 +25,6 @@ function getSupabaseAdmin() {
|
||||
return supabase;
|
||||
}
|
||||
|
||||
async function createTestUser(userData: TestUser): Promise<TestUser> {
|
||||
const supabase = getSupabaseAdmin();
|
||||
|
||||
const { data: authUser, error: authError } = await supabase.auth.signUp({
|
||||
email: userData.email,
|
||||
password: userData.password,
|
||||
});
|
||||
|
||||
if (authError) {
|
||||
throw new Error(`Failed to create test user: ${authError.message}`);
|
||||
}
|
||||
|
||||
return {
|
||||
...userData,
|
||||
id: authUser.user?.id,
|
||||
};
|
||||
}
|
||||
|
||||
async function deleteTestUser(userId: string) {
|
||||
const supabase = getSupabaseAdmin();
|
||||
|
||||
@@ -59,28 +40,3 @@ async function deleteTestUser(userId: string) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function generateUserData(): TestUser {
|
||||
return {
|
||||
email: `test.${faker.string.uuid()}@example.com`,
|
||||
password: faker.internet.password({ length: 12 }),
|
||||
};
|
||||
}
|
||||
|
||||
// Export just the fixture function
|
||||
export const createTestUserFixture = async (
|
||||
{}: {},
|
||||
use: (user: TestUser) => Promise<void>,
|
||||
) => {
|
||||
let user: TestUser | null = null;
|
||||
|
||||
try {
|
||||
const userData = generateUserData();
|
||||
user = await createTestUser(userData);
|
||||
await use(user);
|
||||
} finally {
|
||||
if (user?.id) {
|
||||
await deleteTestUser(user.id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user