I’m finally getting round to figuring out tests on the service side and trying to work out how to create a scenario that will enable me to test some code that makes a simple change to a model that has many relations.
The model that I am updating in my code is for a payment, I am just testing that the status field is updated to ‘SUCCEEDED’.
But, the Payment has a foreign key relation to a Booking, the Booking to a Session, the Session to a Location and to an Activity, and both of those to an Organisation.
If I just create my Payment in my scenario then I get a foreign key related error when I run the test.
export const standard = defineScenario<Prisma.PaymentCreateArgs>({
payment: {
one: {
data: {
provider: 'STRIPE',
currencyCode: 'gbp',
amount: 800,
status: 'NEW',
bookingId: 'one',
providerPaymentId: 'abc123',
},
},
},
})
Is there another way to set this up than to create an organisation, location, activity, session, booking and payment in my scenario?
Or given that I’ll no doubt have to do that again for each other model I want to test, is there a way that I can set this up so that I can import things into my scenario to avoid duplication between scenarios?
Thanks