mercredi 3 mars 2021

Integration testing code that generates GUID/UUID and saves to database

I have an endpoint that saves a NEW USER Entity to a User table (with a GUID as Primary Key). Within this NEW USER entity there are other nested Entities which save the NEW USER Primary Key as their Foreign Keys (These tables also save their own newly generated GUIDS as Primary Keys).

So basically, there are GUIDs being saved into multiple tables and all linking as Primary/Foreign Keys.

My problem is trying to integration test this code and assert that the correct GUIDS are saved as Primary & Foregin keys to the right tables. The issue is that the tests create new GUIDS each time the test is ran... so even if I assign values to these GUIDs in my test, the test will fail because the code generates the GUIDs, and they don't match the GUID test values which I have assigned in my test.

Does anyone know how to force Integration tests to ignore code generated GUIDS for the sake of testing??

Aucun commentaire:

Enregistrer un commentaire