You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...Hooks::beforeEach(function (&$transaction) use ($app) {
$app->make('db')->beginTransaction();
});
Hooks::afterEach(function (&$transaction) use ($app) {
$app->make('db')->rollback();
});
...
does it make sense to make HTTP transaction isolation using such approach?
This code executes inside of bin/dredd-hooks-php process therefore it has own database connection but at the same time API server under test has another connection and doesn't see any uncomitted data of bin/dredd-hooks-php process. So how it should work? May be I should use something like 'Read uncommitted' isolation level of postgres to make it workable? :/
Expected behavior
create test data and save to database inside of before hook
run test
2.1 request data from the API server, server should find and return just created data inside of before hook
2.2 pass the test if data is correct
cleanup database
In Laravel example it made by using beginTransaction/rollback inside of beforeAll/afterAll hooks, but seems it wrong.
What is in your dredd.yml?
color: truedry-run: nullhookfiles: /srv/tests/dredd/bootstrap.phplanguage: /srv/vendor/ddelnano/dredd-hooks-php/bin/dredd-hooks-phprequire: null# null because I use my server which already works on 80 portserver: nullserver-wait: 3init: falsecustom: {}names: falseonly: []reporter: [dot]output: []header: []sorted: falseuser: test:uy5elx0pCYYZZucsoC06TAMq3KewM9inline-errors: falsedetails: falsemethod: []loglevel: debugpath: []hooks-worker-timeout: 5000hooks-worker-connect-timeout: 5000hooks-worker-connect-retry: 500hooks-worker-after-connect-wait: 500hooks-worker-term-timeout: 5000hooks-worker-term-retry: 500hooks-worker-handler-host: 127.0.0.1hooks-worker-handler-port: 61321config: ./dredd.ymlblueprint: swagger.yaml# I run it inside of a dockerendpoint: 'host.docker.internal:80'
What's your dredd --version output?
dredd v11.2.18 (Linux 4.9.93-linuxkit-aufs; x64)
The text was updated successfully, but these errors were encountered:
I'm afraid we're not so experienced here with how db transactions work in Laravel exactly. It might be better idea to file this issue at https://github.com/ddelnano/dredd-hooks-php directly so @ddelnano or other users of the PHP hooks can easily look it up and answer.
This is definitely a known issue (see ddelnano/dredd-hooks-php#34). The example should probably use database migrations rather than transactions (so it can start with a clean slate for every test).
Seems there is a bug https://github.com/ddelnano/dredd-hooks-php/wiki/Laravel-Example
Look on
tests/dredd/hooks/hookfile.php
does it make sense to make HTTP transaction isolation using such approach?
This code executes inside of
bin/dredd-hooks-php
process therefore it has own database connection but at the same time API server under test has another connection and doesn't see any uncomitted data ofbin/dredd-hooks-php
process. So how it should work? May be I should use something like 'Read uncommitted' isolation level of postgres to make it workable? :/Expected behavior
before
hook2.1 request data from the API server, server should find and return just created data inside of
before
hook2.2 pass the test if data is correct
In Laravel example it made by using
beginTransaction/rollback
inside ofbeforeAll/afterAll
hooks, but seems it wrong.What is in your
dredd.yml
?What's your
dredd --version
output?The text was updated successfully, but these errors were encountered: