Skip to content

Commit 870d8a4

Browse files
author
蔡顺铠
committed
Merge pull request 'feat(bootstrap): 添加启动检查断言并更新测试配置' (#9) from fix/init-master into master
Reviewed-on: https://git.dtyq.com/magic/magic/pulls/9
2 parents d464b87 + 74bb0d2 commit 870d8a4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

backend/magic-service/app/Interfaces/Bootstrap/Facade/BootstrapApi.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public function checkStatus(RequestInterface $request): array
5353
*/
5454
public function execute(RequestInterface $request): array
5555
{
56+
$this->assertBootstrapPending();
57+
5658
$requestDTO = BootstrapExecuteRequestDTO::fromRequest($this->request);
5759

5860
return $this->bootstrapInitializationAppService->initialize($requestDTO);
@@ -77,7 +79,7 @@ public function llmConnectivityTest()
7779

7880
protected function assertBootstrapPending(): void
7981
{
80-
if (! $this->magicSettingAppService->get()->isNeedInitial()) {
82+
if (! ($this->checkStatus($this->request)['need_initial'] ?? false)) {
8183
ExceptionBuilder::throw(GenericErrorCode::IllegalOperation, 'bootstrap has already been initialized');
8284
}
8385
}

backend/magic-service/test/Cases/Api/Bootstrap/BootstrapApiTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ private function createApi(
139139
RequestInterface $request,
140140
?MagicSettingAppService $magicSettingAppService = null
141141
): BootstrapApi {
142-
$magicSettingAppService ??= $this->createMock(MagicSettingAppService::class);
142+
if ($magicSettingAppService === null) {
143+
$magicSettingAppService = $this->createMock(MagicSettingAppService::class);
144+
$globalConfig = new GlobalConfig();
145+
$globalConfig->setNeedInitial(true);
146+
$magicSettingAppService->method('getWithoutCache')->willReturn($globalConfig);
147+
}
148+
143149
return new BootstrapApi($request, $magicSettingAppService);
144150
}
145151
}

0 commit comments

Comments
 (0)