-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
123 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PORT=... | ||
API_URL=... | ||
SECRET_KEY=SECRET | ||
TURSO_DATABASE_URL=... | ||
TURSO_AUTH_TOKEN=... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,3 +125,5 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
!.env.example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
export const validUser = { | ||
email: '[email protected]', | ||
password: '12345678' | ||
export const signUpValues = { | ||
validUser: { | ||
email: '[email protected]', | ||
password: '12345678' | ||
}, | ||
invalidUser: { | ||
email: '', | ||
password: '' | ||
} | ||
} | ||
|
||
export const invalidUser = { | ||
email: '', | ||
password: '' | ||
export const signInValues = { | ||
validUser: { | ||
email: '[email protected]', | ||
password: '12345678' | ||
}, | ||
invalidParams: { | ||
email: '[email protected]' | ||
}, | ||
invalidCredentials: { | ||
email: '[email protected]', password: 'wrongpassword' | ||
}, | ||
nonExistentUser: { | ||
email: '[email protected]', password: 'randompass' | ||
} | ||
} | ||
|
||
export const invalidParams = { email: '[email protected]' } | ||
export const invalidCredentials = { email: '[email protected]', password: 'wrongpassword' } | ||
export const nonExistentUser = { email: '[email protected]', password: 'randompass' } | ||
export const signOutValues = { | ||
validUser: { | ||
email: '[email protected]', | ||
password: '12345678' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { db } from '#db/index.js' | ||
import { users } from '#db/schemas/users.js' | ||
import { afterAll, beforeAll } from 'vitest' | ||
// Add your setup.js logic here! You can use the beforeAll and afterAll hooks to run | ||
// something before/after **a describe block** runs. | ||
|
||
beforeAll(async () => { | ||
await db.delete(users) | ||
}) | ||
|
||
afterAll(async () => { | ||
await db.delete(users) | ||
}) | ||
/** | ||
* Notes: | ||
* | ||
* - Using beforeAll and afterAll might be tricky here if you want to do something | ||
* to the global state of your application. Ensure you don't wipe out your whole | ||
* database here! | ||
* | ||
* - If you want to remove data and multiple describe tests depend on them, | ||
* consider adding individual beforeAll and afterAll tests on each describe block! | ||
* See the test suites for an example. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { db } from '#db/index.js' | ||
import { users } from '#db/schemas/users.js' | ||
import { inArray } from 'drizzle-orm' | ||
/** | ||
* Remove users given by object. Each key should contain an | ||
* object with information about an user. See 'mocks/users.js' for | ||
* an example of an object | ||
* | ||
* @param {users} userData the user data. Must contain at least the email | ||
* to uniquely identify users. | ||
*/ | ||
export async function cleanUsers (userData) { | ||
// extract all distinct emails | ||
const emails = Object.values(userData) | ||
.map((entry) => entry.email) | ||
.filter((email, index, self) => email && self.indexOf(email) === index) | ||
|
||
if (emails.length === 0) { | ||
return | ||
} | ||
|
||
// try to delete all the emails from the user object | ||
try { | ||
const result = await db | ||
.delete(users) | ||
.where(inArray(users.email, emails)) | ||
.returning({ email: users.email }) | ||
|
||
console.log('Deleted users:', result) | ||
|
||
return result | ||
} catch (error) { | ||
console.error('Error deleting users:', error) | ||
} | ||
} |