Access of \OC in tests acceptable?

Hello there,

I am currently considering reworking my tests (of the cookbook app) and extending them in a more in-depth fashion. More precisely, I plan to introduce some migrations in the future that need to actually migrate data. That means, things can go wrong and it would be nice to have these (data) migrations tested before hitting a bigger user base.

After a bit or research (both AI and non-AI), I am convinced that my current way of working is not going bring a good solution for me: in the current test suite, I have a very intensive way to test it by restoring a complete NC installation in each test run. Effectively, this makes the tests extremely slow and debugging/iteration is time-consuming and tiring.

I got the idea to do it a bit differently. Instead of restoring the complete NC instance (which takes significant amount of time), I start by dropping all DB tables related to my app (also these that existed in the past) if existing. Then, I reset the migrations in oc_migrations, effectively creating a vanilla state regarding the cookbook. Starting from there, the idea is to migrate the schema to a certain step (just before the migration to be tested), set up the data and DB and run the migration under consideration.

The problem is that I would need to access the class OC\DB\MigrationService from within the test code, ideally to reestablish the database structure for the database. That means, the actual code as running on the users’ instances will be still free of private API access. However, the build pipeline might be depending on this private API of the server.

I wanted to ask about your opinion and if you see stable alternatives for this. Did I miss an obvious way to handle this?

Thanks for your feedback
Christian