adamchainz/django-perf-rec

`MODE` option to assert on records for tests which don't exist

Closed this issue · 2 comments

Description

It would be great if there was a MODE option to assert on tests which don't exist any more. This would ensure for example when removing old tests that the query records were also removed. In turn that would simplify the process of regenerating the records when large-scale changes are made, since the resulting diff wouldn't be a mix of missing records (from dead tests) and the effect of the actual changes.

Unfortunately my use-case is complicated further by having two environments in which tests are run, which we achieve by mangling the record_name passed to django_perf_rec.record, (I use a similar approach to work around #346) so several test runs are needed to build up a full query record file.

I'm not sure what a solution to this would look like (especially given that record_name is customisable), but it would be interesting to know whether this impacts other users and if so whether there are any good approaches to dealing with this.

If you can come up with a solution I'd be happy to look at it. Perhaps at the end of a test run, unused records could be discarded. That wouldn't help your use case, but perhaps you could split into different files per test run rather than different record names.

Otherwise, we could just have a recommendation that you regenerate records once in a while, not only when doing large scale changes.

This would be nice to have but since it's far from critical, I'm gonna close it for now.