<?php

namespace Tests\Feature;

use App\Models\WgTrafficSample;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use Tests\TestCase;

class WgTrafficSampleTest extends TestCase
{
    use RefreshDatabase;

    public function test_persists_and_casts_a_sample(): void
    {
        $s = WgTrafficSample::create([
            'peer_pubkey' => 'abc', 'peer_name' => 'laptop', 'rx' => 1000, 'tx' => 2000, 'sampled_at' => now(),
        ]);

        $this->assertDatabaseHas('wg_traffic_samples', ['peer_pubkey' => 'abc', 'rx' => 1000]);
        $this->assertInstanceOf(Carbon::class, $s->fresh()->sampled_at);
    }
}
