fix: db
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Feature;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Device;
|
||||
use App\Services\CorunaCrypto;
|
||||
use App\Services\IngestService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
@@ -176,4 +177,21 @@ class NewBuilderIngestTest extends TestCase
|
||||
|
||||
$this->assertSame(self::CHANNEL_ID, Device::query()->where('device_id', '000C30D83CD0402E')->value('channel_id'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function create_device_race_returns_existing_row(): void
|
||||
{
|
||||
$existing = Device::query()->create(['device_id' => '000007B46A3A84B8']);
|
||||
$method = new \ReflectionMethod(IngestService::class, 'createDevice');
|
||||
$device = $method->invoke(
|
||||
app(IngestService::class),
|
||||
\Illuminate\Http\Request::create('/event', 'POST'),
|
||||
['d' => '000007B46A3A84B8'],
|
||||
'000007B46A3A84B8',
|
||||
false,
|
||||
);
|
||||
|
||||
$this->assertSame($existing->id, $device->id);
|
||||
$this->assertSame(1, Device::query()->count());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user