Load dev env vars via roadrunner instead of docker compose

This commit is contained in:
Alejandro Celaya 2024-10-22 15:31:47 +02:00
parent c8e5196aab
commit c0200317dd
3 changed files with 22 additions and 23 deletions

View File

@ -74,4 +74,4 @@ CMD \
# Download roadrunner binary
if [[ ! -f "./bin/rr" ]]; then ./vendor/bin/rr get --no-interaction --no-config --location bin/ && chmod +x bin/rr ; fi && \
# Run with `exec` so that signals are properly handled
exec ./bin/rr serve -c config/roadrunner/.rr.dev.yml
exec ./bin/rr serve --dotenv /home/shlink/shlink-dev.env -c config/roadrunner/.rr.dev.yml

View File

@ -63,9 +63,6 @@ services:
- shlink_matomo
environment:
DEFAULT_DOMAIN: localhost:8800
env_file:
- path: shlink-dev.env
required: false
extra_hosts:
- 'host.docker.internal:host-gateway'

View File

@ -7,8 +7,11 @@ namespace ShlinkioTest\Shlink\Core\Config\PostProcessor;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Config\EnvVars;
use Shlinkio\Shlink\Core\Config\PostProcessor\MultiSegmentSlugProcessor;
use function putenv;
class MultiSegmentSlugProcessorTest extends TestCase
{
private MultiSegmentSlugProcessor $processor;
@ -18,36 +21,35 @@ class MultiSegmentSlugProcessorTest extends TestCase
$this->processor = new MultiSegmentSlugProcessor();
}
#[Test, DataProvider('provideConfigs')]
public function parsesRoutesAsExpected(array $config, array $expectedRoutes): void
protected function tearDown(): void
{
self::assertEquals($expectedRoutes, ($this->processor)($config)['routes'] ?? []);
putenv(EnvVars::MULTI_SEGMENT_SLUGS_ENABLED->value);
}
#[Test, DataProvider('provideConfigs')]
public function parsesRoutesAsExpected(bool $multiSegmentEnabled, array $routes, array $expectedRoutes): void
{
putenv(EnvVars::MULTI_SEGMENT_SLUGS_ENABLED->value . '=' . ($multiSegmentEnabled ? 'true' : 'false'));
self::assertEquals($expectedRoutes, ($this->processor)(['routes' => $routes])['routes'] ?? []);
}
public static function provideConfigs(): iterable
{
yield [[], []];
yield [['url_shortener' => []], []];
yield [['url_shortener' => ['multi_segment_slugs_enabled' => false]], []];
yield [
[
'url_shortener' => ['multi_segment_slugs_enabled' => false],
'routes' => $routes = [
['path' => '/foo'],
['path' => '/bar/{shortCode}'],
['path' => '/baz/{shortCode}/foo'],
],
false,
$routes = [
['path' => '/foo'],
['path' => '/bar/{shortCode}'],
['path' => '/baz/{shortCode}/foo'],
],
$routes,
];
yield [
true,
[
'url_shortener' => ['multi_segment_slugs_enabled' => true],
'routes' => [
['path' => '/foo'],
['path' => '/bar/{shortCode}'],
['path' => '/baz/{shortCode}/foo'],
],
['path' => '/foo'],
['path' => '/bar/{shortCode}'],
['path' => '/baz/{shortCode}/foo'],
],
[
['path' => '/foo'],