feat: add tests, chore: update readme

This commit is contained in:
Benjamin Nussbaum 2025-03-03 22:20:52 +01:00
parent 715e6a2562
commit e6a2bdb3bc
27 changed files with 1179 additions and 299 deletions

View file

@ -14,12 +14,17 @@ class DeviceFactory extends Factory
public function definition(): array
{
return [
'name' => $this->faker->firstName().' TRMNL',
'name' => $this->faker->firstName().'\'s TRMNL',
'mac_address' => $this->faker->macAddress(),
'default_refresh_interval' => '900',
'friendly_id' => Str::random(6),
'api_key' => 'tD-'.Str::random(19),
'user_id' => 1,
'last_battery_voltage' => $this->faker->randomFloat(2, 3.0, 4.2),
'last_rssi_level' => $this->faker->numberBetween(-100, 0),
'last_firmware_version' => '1.6.0',
'proxy_cloud' => $this->faker->boolean(),
'last_log_request' => ['status' => 'success', 'timestamp' => Carbon::now()->toDateTimeString()],
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];

View file

@ -29,6 +29,7 @@ class UserFactory extends Factory
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'assign_new_devices' => false,
];
}

View file

@ -2,10 +2,12 @@
namespace Database\Seeders;
use App\Models\Device;
use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class DatabaseSeeder extends Seeder
{
/**
@ -13,12 +15,14 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
if (app()->isLocal()) {
User::factory()->create([
'name' => 'Test User',
'email' => 'admin@example.com',
'password' => bcrypt('admin@example.com'),
]);
User::factory()->create([
'name' => 'Test User',
'email' => 'admin@example.com',
'password' => bcrypt('admin@example.com'),
]);
// Device::factory(5)->create();
}
}
}