<?php

namespace Tests\Feature;

use App\Models\Setting;
use App\Services\ReleaseChecker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class ReleaseCheckerChannelTest extends TestCase
{
    use RefreshDatabase;

    public function test_channel_is_always_stable_even_if_a_prerelease_setting_lingers(): void
    {
        Setting::put('release_channel', 'rc'); // a stale setting from before the drop
        $this->assertSame('stable', app(ReleaseChecker::class)->channel());
    }

    public function test_newest_version_ignores_rc_prereleases(): void
    {
        $checker = app(ReleaseChecker::class);
        $tags = ['v0.11.0', 'v0.12.0-rc1', 'v0.12.0-rc2', 'v0.10.0'];
        $this->assertSame('0.11.0', $checker->newestVersion($tags, 'stable'));
    }
}
