Skip to content

Commit

Permalink
👷 Adding test to validate disabled configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoapaes committed Jun 3, 2022
1 parent ac05aab commit 29c3397
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,37 @@ jobs:
exit 1;
fi
- name: Run tests config disabled
if: matrix.PHP == '80'
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
docker-compose -f docker-compose.yml \
-f docker-compose-${PHP_VERSION}.yml \
-f docker-compose-config-disabled.yml \
up --build -d
echo $(docker run -t --network lemp jwilder/dockerize \
-wait http://core_nginx/ \
-timeout 60s)
docker ps -a
docker logs app
CONTENT=$(curl -s "http://127.0.0.1/");
echo "CHAMADA HTTP: ${CONTENT}";
if [ "${CONTENT}" != "core|${PHP_VERSION}|empty" ]; then
echo "Chamada HTTP retornou errado: ${CONTENT}"
exit 1;
fi
docker-compose -f docker-compose.yml \
-f docker-compose-${PHP_VERSION}.yml \
-f docker-compose-config-disabled.yml \
down -v
- name: Run tests prod
env:
PHP_VERSION: ${{ matrix.PHP }}
Expand Down
7 changes: 7 additions & 0 deletions docker-compose-config-disabled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3.5'

services:

app:
environment:
- CONFIG_DISABLED=true
2 changes: 2 additions & 0 deletions events/src-copied
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ configure-volumes;

if [ -z $CONFIG_DISABLED ]; then
configure-db;
else
echo "config-db: está desabilitado!";
fi

configure-app ${APP_NAME};
18 changes: 18 additions & 0 deletions www80/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
$versaoPhpFormatadaComPonto = $versaoPhp[0] . '.' . $versaoPhp[1];

$config = parse_ini_file(__DIR__ . "/../config.ini", true);

$emptyConfig = [
'bd' => [
'host' => '',
'user' => '',
'password' => '',
'bd' => ''
],
'php' => [
'version' => $versaoPhpFormatadaComPonto
]
];

$expectedConfig = [
'bd' => [
'host' => 'mysql',
Expand Down Expand Up @@ -65,6 +78,11 @@
}

if( count($validation) > 0 ) {
if($config === $emptyConfig) {
echo "core" . "|" . $versaoPhpFormatada . "|empty";
return;
}

echo "<pre>";
echo join("\n", $validation);
var_dump($config);
Expand Down

0 comments on commit 29c3397

Please sign in to comment.