Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function run(): void
]);

/** @phpstan-ignore-next-line argument.type */
tap(Schedule::create([
$documentationMaintenance = tap(Schedule::create([
'name' => 'Documentation Maintenance',
'message' => 'We will be conducting maintenance on our documentation servers. You may experience degraded performance during this time.',
'scheduled_at' => now()->addHours(24),
Expand All @@ -79,7 +79,7 @@ public function run(): void
});

/** @phpstan-ignore-next-line argument.type */
tap(Schedule::create([
$databaseUpgrade = tap(Schedule::create([
'name' => 'Database Server Upgrade',
'message' => 'We upgraded our primary database servers to improve performance and reliability.',
'scheduled_at' => now()->subHours(26),
Expand Down Expand Up @@ -138,6 +138,14 @@ public function run(): void
'checked' => true,
]);

$documentationMaintenance->components()->attach($documentation, [
'component_status' => ComponentStatusEnum::performance_issues,
]);

$databaseUpgrade->components()->attach($website, [
'component_status' => ComponentStatusEnum::partial_outage,
]);

$metric = Metric::create([
'name' => DemoMetricSeeder::METRIC_NAME,
'suffix' => 'req/s',
Expand Down
27 changes: 27 additions & 0 deletions tests/Unit/Database/DatabaseSeederTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Cachet\Database\Seeders\DatabaseSeeder;
use Cachet\Enums\ComponentStatusEnum;
use Cachet\Models\Schedule;

it('assigns affected components to the demo maintenance schedules', function () {
$this->seed(DatabaseSeeder::class);

$documentationMaintenance = Schedule::query()
->where('name', 'Documentation Maintenance')
->firstOrFail();
$databaseUpgrade = Schedule::query()
->where('name', 'Database Server Upgrade')
->firstOrFail();

expect($documentationMaintenance->components)
->toHaveCount(1)
->first()->name->toBe('Cachet Documentation')
->and($documentationMaintenance->components->first()->pivot->component_status)
->toBe(ComponentStatusEnum::performance_issues)
->and($databaseUpgrade->components)
->toHaveCount(1)
->first()->name->toBe('Cachet Website')
->and($databaseUpgrade->components->first()->pivot->component_status)
->toBe(ComponentStatusEnum::partial_outage);
});
Loading