Merge branch 'feature/seed-user'
This commit is contained in:
commit
7ebffd18b3
4 changed files with 47 additions and 1 deletions
|
|
@ -11,5 +11,6 @@ class DatabaseSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
|
$this->call(UserSeeder::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
backend/database/seeders/UserSeeder.php
Normal file
16
backend/database/seeders/UserSeeder.php
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\User\UserModel;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class UserSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
UserModel::firstOrCreate([
|
||||||
|
'email' => 'user@example.com',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
backend/tests/Feature/Database/DatabaseSeederTest.php
Normal file
22
backend/tests/Feature/Database/DatabaseSeederTest.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Database;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class DatabaseSeederTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
public function test_it_seeds_the_development_user_idempotently(): void
|
||||||
|
{
|
||||||
|
$this->seed();
|
||||||
|
$this->seed();
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('users', [
|
||||||
|
'email' => 'user@example.com',
|
||||||
|
]);
|
||||||
|
$this->assertDatabaseCount('users', 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,13 @@ processes:
|
||||||
postgres:
|
postgres:
|
||||||
condition: process_healthy
|
condition: process_healthy
|
||||||
|
|
||||||
|
seed:
|
||||||
|
command: php artisan db:seed --force
|
||||||
|
working_dir: ./backend
|
||||||
|
depends_on:
|
||||||
|
migrate:
|
||||||
|
condition: process_completed_successfully
|
||||||
|
|
||||||
mailpit:
|
mailpit:
|
||||||
command: mailpit --smtp 127.0.0.1:${MAILPIT_SMTP_PORT:-2525} --listen 127.0.0.1:${MAILPIT_UI_PORT:-8025}
|
command: mailpit --smtp 127.0.0.1:${MAILPIT_SMTP_PORT:-2525} --listen 127.0.0.1:${MAILPIT_UI_PORT:-8025}
|
||||||
readiness_probe:
|
readiness_probe:
|
||||||
|
|
@ -32,7 +39,7 @@ processes:
|
||||||
command: php artisan serve --host=127.0.0.1 --port=${BACKEND_PORT:-8001}
|
command: php artisan serve --host=127.0.0.1 --port=${BACKEND_PORT:-8001}
|
||||||
working_dir: ./backend
|
working_dir: ./backend
|
||||||
depends_on:
|
depends_on:
|
||||||
migrate:
|
seed:
|
||||||
condition: process_completed_successfully
|
condition: process_completed_successfully
|
||||||
mailpit:
|
mailpit:
|
||||||
condition: process_healthy
|
condition: process_healthy
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue