Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-3639]: fix/get existing customer #150

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

xabg2
Copy link
Collaborator

@xabg2 xabg2 commented Jan 17, 2025

Using the uuid to get the existing user from our DB if it exists before creating a new one in Stripe when calling POST /create-customer. Also, we get the user by uuid when payment invoices are completed to update it in the DB if needed.

@xabg2 xabg2 added the bug Something isn't working label Jan 17, 2025
@xabg2 xabg2 self-assigned this Jan 17, 2025
@xabg2 xabg2 marked this pull request as ready for review February 6, 2025 13:56
@xabg2 xabg2 requested a review from sg-gs as a code owner February 6, 2025 13:56
src/server.ts Outdated
const start = async (mongoTestClient?: MongoClient): Promise<FastifyInstance> => {
const start = async (
mongoTestClient?: MongoClient,
mocksServices?: {
Copy link
Member

@sg-gs sg-gs Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a very bad idea. Tests are for covering the real codebase, you cannot mix both things. What you need to do here involves mechanisms like sinon's stub method, which will save you from editing the codebase to have tests working.

@@ -9,6 +9,16 @@ import { Tier } from '../../../src/core/users/MongoDBTiersRepository';
const randomDataGenerator = new Chance();

export default function getMocks() {
const user = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can use functions to instantiate mocks instead of having to create a const each time, that would be cleaner, easier to use and faster to work with. Example here where you can instantiate a user, by default it has as real as possible fields (using chance). It has of course things to improve, but it's far more scalable than this way of creating mocks.

@xabg2 xabg2 requested a review from sg-gs February 7, 2025 09:18
Copy link

sonarqubecloud bot commented Feb 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
77.8% Coverage on New Code (required ≥ 85%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-for-preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants