mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
Guard against wiping database when running tests and test specific envs are not created
This commit is contained in:
parent
4845a88c68
commit
48e4ec8cf5
|
@ -23,7 +23,9 @@ pipeline:
|
||||||
- name: Setup
|
- name: Setup
|
||||||
cmd: |
|
cmd: |
|
||||||
cp -v .env.example .env
|
cp -v .env.example .env
|
||||||
|
# This is simply to allow passing the guard in TestCase@setUp()
|
||||||
|
# https://chipperci.com/docs/builds/env
|
||||||
|
touch .env.testing
|
||||||
composer install --no-interaction --prefer-dist --optimize-autoloader
|
composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
- name: Generate Key
|
- name: Generate Key
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Facebook\WebDriver\Remote\DesiredCapabilities;
|
||||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Laravel\Dusk\TestCase as BaseTestCase;
|
use Laravel\Dusk\TestCase as BaseTestCase;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
abstract class DuskTestCase extends BaseTestCase
|
abstract class DuskTestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
@ -21,6 +22,12 @@ abstract class DuskTestCase extends BaseTestCase
|
||||||
*/
|
*/
|
||||||
public static function prepare()
|
public static function prepare()
|
||||||
{
|
{
|
||||||
|
if (!file_exists(realpath(__DIR__ . '/../') . '/.env.dusk.local')) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
'.env.dusk.local file does not exist. Aborting to avoid wiping your local database'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (! static::runningInSail()) {
|
if (! static::runningInSail()) {
|
||||||
static::startChromeDriver();
|
static::startChromeDriver();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace Tests;
|
||||||
use App\Http\Middleware\SecurityHeaders;
|
use App\Http\Middleware\SecurityHeaders;
|
||||||
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
||||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||||
|
use RuntimeException;
|
||||||
use Tests\Support\CustomTestMacros;
|
use Tests\Support\CustomTestMacros;
|
||||||
use Tests\Support\InteractsWithAuthentication;
|
use Tests\Support\InteractsWithAuthentication;
|
||||||
use Tests\Support\InteractsWithSettings;
|
use Tests\Support\InteractsWithSettings;
|
||||||
|
@ -22,6 +23,12 @@ abstract class TestCase extends BaseTestCase
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
|
if (!file_exists(realpath(__DIR__ . '/../') . '/.env.testing')) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
'.env.testing file does not exist. Aborting to avoid wiping your local database'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
||||||
|
|
Loading…
Reference in a new issue