This commit is contained in:
hashbro
2026-08-26 03:14:15 +08:00
parent 5c9ceca4ea
commit 5cb5744b7a
10 changed files with 227 additions and 45 deletions
@@ -542,6 +542,64 @@ class ChannelProjectServiceTest extends TestCase
$this->assertDatabaseMissing('channels', ['id' => $channel->id]);
}
#[Test]
public function it_rebuilds_existing_new_channels_with_shared_build_once(): void
{
$this->stageFakeWeifile();
Channel::query()->create([
'channel_id' => '0.0.01',
'builder_type' => Channel::BUILDER_NEW,
'user_id' => 0,
'status' => 1,
]);
Channel::query()->create([
'channel_id' => self::NEW_CHANNEL_ID,
'builder_type' => Channel::BUILDER_NEW,
'user_id' => 0,
'status' => 1,
]);
Channel::query()->create([
'channel_id' => self::CHANNEL_ID,
'builder_type' => Channel::BUILDER_OLD,
'user_id' => 0,
'status' => 1,
]);
Process::fake([
'*' => Process::result(output: $this->fakeBuildResult([
'builder_type' => 'new',
'landing_path' => '/channel/0.0.01/weifile/weifile.html',
'details_path' => '/channel/0.0.01/details/',
'channel_dir' => '/channel/0.0.01',
])),
]);
$result = app(ChannelProjectService::class)->rebuildNewChannels();
$this->assertSame(['0.0.01', self::NEW_CHANNEL_ID], array_column($result['channels'], 'channel_id'));
$this->assertArrayHasKey('shared', $result);
Process::assertRanTimes(function ($process) {
$joined = is_array($process->command) ? implode(' ', $process->command) : (string) $process->command;
return str_contains($joined, 'build.py') && str_contains($joined, '--channel-c');
}, 1);
Process::assertRanTimes(function ($process) {
$joined = is_array($process->command) ? implode(' ', $process->command) : (string) $process->command;
return str_contains($joined, 'pack_channel.py');
}, 2);
Process::assertRan(function ($process) {
$joined = is_array($process->command) ? implode(' ', $process->command) : (string) $process->command;
return str_contains($joined, 'pack_channel.py') && str_contains($joined, '0.0.01');
});
Process::assertRan(function ($process) {
$joined = is_array($process->command) ? implode(' ', $process->command) : (string) $process->command;
return str_contains($joined, 'pack_channel.py') && str_contains($joined, self::NEW_CHANNEL_ID);
});
}
#[Test]
public function version_format_required_for_new_channel_ids(): void
{