-
Notifications
You must be signed in to change notification settings - Fork 280
[feature request] Allow Hooks to Be Configured For Database Transactions #257
Comments
Ah forgot about the nodejs hooks but same holds true. |
Hi @ddelnano, may I know why did you close this? Is it not valid anymore? |
I was assuming when I opened this that there was going to be some discussion about the request. The reason I say that is cause I didn't want to incorporate something into the PHP hooks unless the others all had the same feature set. |
Do you agree with my thinking on that the hooks should have the same feature set??? I also closed it because to allow transactions would be hard cause it would require the user to provide the same database connection that their application is using and so it causes potential issues where users would be seeding the database in one connection and the web app would be accessing the database in another. Allowing an interface to run migrations before and after tests would be a much better option since it wouldn't require the same connection and still allow the database to be clean between tests. |
I'm facing the same situation in Python side. |
My opinion would be that all hooks implementations should conform to the same base feature set and it's up to their authors to try out innovations. If those innovations prove to be useful, they can get incorporated back as a standard feature in Dredd (one thing which pops in my head would be Of course, when introducing innovations, authors of hooks risk future need for backwards-incompatible changes when the common implementation would be slightly different or behave slightly differently than what was originally introduced. But that's life. Without innovations and risk, there's no progress! 🚀 |
As it currently stands, I need to configure a
beforeEach
andafterEach
hook in order to run everything in a transaction and roll it back so I have a clean database for each run. I think it would be useful to have the Hooks be able to accept a database connection that implements an interface for running or rolling back a migration (That is how it would work in PHP anyway).So essentially you would set the
Hooks::$databaseConnection
property in the hooksfile like so:And the Hooks.php
This
DatabaseConnection
class would implement an interface that would expose astartTransaction
androllback
method and from theDredd\Runner
side of things make a check on thebeforeEach
andafterEach
hook to see if it is configured and if so start and rollback the transactions as necessary.This way for each project I am on I don't need to configure this
beforeEach
andafterEach
hook boiler plate.I have done very little Python and Ruby programming, however, I do know that they don't have interfaces but from the PHP side thats a basic overview. Not exactly sure what the Ruby or Python way of dealing with this is, but if people like this idea I would like to give the implementation a try in the Python or Ruby as well as the PHP side of things.
The text was updated successfully, but these errors were encountered: