Skip to content

Commit 0ea888a

Browse files
committed
Show proper message if seeding while board is stopped
1 parent 0680a5f commit 0ea888a

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎src/QuickInstall/Sandbox/BoardService.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ public function seed(string $name, string $preset, int $seed, string $action): v
150150
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.');
151151
}
152152

153-
$this->createBoardRunner()->seed($name, $preset, $seed, $action);
153+
$runner = $this->createBoardRunner();
154+
if ($runner->status($name) !== 'running')
155+
{
156+
throw new RuntimeException('Board must be running before seeding. Start it first.');
157+
}
158+
159+
$runner->seed($name, $preset, $seed, $action);
154160
}
155161

156162
protected function createBoardRunner(): BoardRunner

‎tests/Unit/BoardServiceTest.php‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function testStartStopDestroyAndSeedDelegateToRunner(): void
9292
$project = $this->projectWithSource('3.3.14');
9393
$project->appendBoard(['name' => 'demo', 'db' => 'mariadb']);
9494
$runner = new ServiceTestBoardRunner($project);
95+
$runner->statuses['demo'] = 'running';
9596
$service = new TestBoardService($project, $runner);
9697

9798
self::assertSame('demo', $service->start('demo')['name']);
@@ -105,6 +106,19 @@ public function testStartStopDestroyAndSeedDelegateToRunner(): void
105106
self::assertSame(['demo'], $runner->destroyed);
106107
}
107108

109+
public function testSeedRequiresRunningBoard(): void
110+
{
111+
$project = $this->projectWithSource('3.3.14');
112+
$project->appendBoard(['name' => 'demo', 'db' => 'mariadb']);
113+
$runner = new ServiceTestBoardRunner($project);
114+
$runner->statuses['demo'] = 'stopped';
115+
116+
$this->expectException(\RuntimeException::class);
117+
$this->expectExceptionMessage('Board must be running before seeding. Start it first.');
118+
119+
(new TestBoardService($project, $runner))->seed('demo', 'tiny', 1, 'seed');
120+
}
121+
108122
/**
109123
* @dataProvider sqliteSeedActionProvider
110124
*/
@@ -113,6 +127,7 @@ public function testSqliteSeedActionRules(string $action, bool $allowed): void
113127
$project = $this->projectWithSource('3.3.14');
114128
$project->appendBoard(['name' => 'demo', 'db' => 'sqlite']);
115129
$runner = new ServiceTestBoardRunner($project);
130+
$runner->statuses['demo'] = 'running';
116131

117132
if (!$allowed)
118133
{

0 commit comments

Comments
 (0)