mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 09:03:07 +03:00
Merge pull request #1052 from acelaya-forks/feature/api-test-logs
Feature/api test logs
This commit is contained in:
commit
60a8d6e986
5 changed files with 26 additions and 2 deletions
|
@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
||||||
### Changed
|
### Changed
|
||||||
* [#1036](https://github.com/shlinkio/shlink/issues/1036) Updated to `happyr/doctrine-specification` 2.0.
|
* [#1036](https://github.com/shlinkio/shlink/issues/1036) Updated to `happyr/doctrine-specification` 2.0.
|
||||||
* [#1039](https://github.com/shlinkio/shlink/issues/1039) Updated to `endroid/qr-code` 4.0.
|
* [#1039](https://github.com/shlinkio/shlink/issues/1039) Updated to `endroid/qr-code` 4.0.
|
||||||
|
* [#1008](https://github.com/shlinkio/shlink/issues/1008) Ensured all logs are sent to the filesystem while running API tests, which helps debugging the reason for tests to fail.
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|
|
@ -96,12 +96,14 @@ In order to ensure stability and no regressions are introduced while developing
|
||||||
|
|
||||||
The project provides some tooling to run them against any of the supported database engines.
|
The project provides some tooling to run them against any of the supported database engines.
|
||||||
|
|
||||||
* **API tests**: These are E2E tests that spin up an instance of the app and test it from the outside, by interacting with the REST API.
|
* **API tests**: These are E2E tests that spin up an instance of the app with swoole, and test it from the outside by interacting with the REST API.
|
||||||
|
|
||||||
These are the best tests to catch regressions, and to verify everything behaves as expected.
|
These are the best tests to catch regressions, and to verify everything behaves as expected.
|
||||||
|
|
||||||
They use Postgres as the database engine, and include some fixtures that ensure the same data exists at the beginning of the execution.
|
They use Postgres as the database engine, and include some fixtures that ensure the same data exists at the beginning of the execution.
|
||||||
|
|
||||||
|
Since the app instance is run on a process different from the one running the tests, when a test fails it might not be obvious why. To help debugging that, the app will dump all its logs inside `data/log/api-tests`, where you will find the `shlink.log` and `access.log` files.
|
||||||
|
|
||||||
* **CLI tests**: *TBD. Once included, its purpose will be the same as API tests, but running through the command line*
|
* **CLI tests**: *TBD. Once included, its purpose will be the same as API tests, but running through the command line*
|
||||||
|
|
||||||
Depending on the kind of contribution, maybe not all kinds of tests are needed, but the more you provide, the better.
|
Depending on the kind of contribution, maybe not all kinds of tests are needed, but the more you provide, the better.
|
||||||
|
|
|
@ -3,6 +3,8 @@ export APP_ENV=test
|
||||||
export DB_DRIVER=postgres
|
export DB_DRIVER=postgres
|
||||||
export TEST_ENV=api
|
export TEST_ENV=api
|
||||||
|
|
||||||
|
rm -rf data/log/api-tests
|
||||||
|
|
||||||
# Try to stop server just in case it hanged in last execution
|
# Try to stop server just in case it hanged in last execution
|
||||||
vendor/bin/laminas mezzio:swoole:stop
|
vendor/bin/laminas mezzio:swoole:stop
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"laminas/laminas-stdlib": "^3.2",
|
"laminas/laminas-stdlib": "^3.2",
|
||||||
"lcobucci/jwt": "^4.0",
|
"lcobucci/jwt": "^4.0",
|
||||||
"league/uri": "^6.2",
|
"league/uri": "^6.2",
|
||||||
"lstrojny/functional-php": "^1.15",
|
"lstrojny/functional-php": "^1.17",
|
||||||
"mezzio/mezzio": "^3.3",
|
"mezzio/mezzio": "^3.3",
|
||||||
"mezzio/mezzio-fastroute": "^3.1",
|
"mezzio/mezzio-fastroute": "^3.1",
|
||||||
"mezzio/mezzio-problem-details": "^1.3",
|
"mezzio/mezzio-problem-details": "^1.3",
|
||||||
|
|
|
@ -9,6 +9,8 @@ use Laminas\ConfigAggregator\ConfigAggregator;
|
||||||
use Laminas\Diactoros\Response\EmptyResponse;
|
use Laminas\Diactoros\Response\EmptyResponse;
|
||||||
use Laminas\ServiceManager\Factory\InvokableFactory;
|
use Laminas\ServiceManager\Factory\InvokableFactory;
|
||||||
use Laminas\Stdlib\Glob;
|
use Laminas\Stdlib\Glob;
|
||||||
|
use Monolog\Handler\StreamHandler;
|
||||||
|
use Monolog\Logger;
|
||||||
use PDO;
|
use PDO;
|
||||||
use PHPUnit\Runner\Version;
|
use PHPUnit\Runner\Version;
|
||||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||||
|
@ -80,6 +82,18 @@ $buildDbConnection = function (): array {
|
||||||
return $driverConfigMap[$driver] ?? [];
|
return $driverConfigMap[$driver] ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$buildTestLoggerConfig = fn (string $handlerName, string $filename) => [
|
||||||
|
'handlers' => [
|
||||||
|
$handlerName => [
|
||||||
|
'name' => StreamHandler::class,
|
||||||
|
'params' => [
|
||||||
|
'level' => Logger::DEBUG,
|
||||||
|
'stream' => sprintf('data/log/api-tests/%s', $filename),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'debug' => true,
|
'debug' => true,
|
||||||
|
@ -163,4 +177,9 @@ return [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'logger' => [
|
||||||
|
'Shlink' => $buildTestLoggerConfig('shlink_handler', 'shlink.log'),
|
||||||
|
'Access' => $buildTestLoggerConfig('access_handler', 'access.log'),
|
||||||
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue