diff --git a/src/QuickInstall/Sandbox/BoardService.php b/src/QuickInstall/Sandbox/BoardService.php index 1577db96..d43413d0 100644 --- a/src/QuickInstall/Sandbox/BoardService.php +++ b/src/QuickInstall/Sandbox/BoardService.php @@ -150,7 +150,13 @@ public function seed(string $name, string $preset, int $seed, string $action): v throw new InvalidArgumentException('SQLite boards do not support fixture seeding. Use --reset to remove partial seed data, or use mariadb, mysql, or postgres for seeded boards.'); } - $this->createBoardRunner()->seed($name, $preset, $seed, $action); + $runner = $this->createBoardRunner(); + if ($runner->status($name) !== 'running') + { + throw new RuntimeException('Board must be running before seeding. Start it first.'); + } + + $runner->seed($name, $preset, $seed, $action); } protected function createBoardRunner(): BoardRunner diff --git a/tests/Unit/BoardServiceTest.php b/tests/Unit/BoardServiceTest.php index 0eea109e..3e36209e 100644 --- a/tests/Unit/BoardServiceTest.php +++ b/tests/Unit/BoardServiceTest.php @@ -92,6 +92,7 @@ public function testStartStopDestroyAndSeedDelegateToRunner(): void $project = $this->projectWithSource('3.3.14'); $project->appendBoard(['name' => 'demo', 'db' => 'mariadb']); $runner = new ServiceTestBoardRunner($project); + $runner->statuses['demo'] = 'running'; $service = new TestBoardService($project, $runner); self::assertSame('demo', $service->start('demo')['name']); @@ -105,6 +106,19 @@ public function testStartStopDestroyAndSeedDelegateToRunner(): void self::assertSame(['demo'], $runner->destroyed); } + public function testSeedRequiresRunningBoard(): void + { + $project = $this->projectWithSource('3.3.14'); + $project->appendBoard(['name' => 'demo', 'db' => 'mariadb']); + $runner = new ServiceTestBoardRunner($project); + $runner->statuses['demo'] = 'stopped'; + + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Board must be running before seeding. Start it first.'); + + (new TestBoardService($project, $runner))->seed('demo', 'tiny', 1, 'seed'); + } + /** * @dataProvider sqliteSeedActionProvider */ @@ -113,6 +127,7 @@ public function testSqliteSeedActionRules(string $action, bool $allowed): void $project = $this->projectWithSource('3.3.14'); $project->appendBoard(['name' => 'demo', 'db' => 'sqlite']); $runner = new ServiceTestBoardRunner($project); + $runner->statuses['demo'] = 'running'; if (!$allowed) {