feat: add HasFactory and factories for ApiLog, BrentPrice, PricePrediction
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
31
database/factories/ApiLogFactory.php
Normal file
31
database/factories/ApiLogFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\ApiLog;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<ApiLog> */
|
||||
class ApiLogFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'service' => fake()->randomElement(['fuel_finder', 'fred', 'anthropic', 'postcodes_io']),
|
||||
'method' => fake()->randomElement(['GET', 'POST']),
|
||||
'url' => fake()->url(),
|
||||
'status_code' => fake()->randomElement([200, 200, 200, 401, 429, 500]),
|
||||
'duration_ms' => fake()->numberBetween(50, 2000),
|
||||
'error' => null,
|
||||
'created_at' => fake()->dateTimeBetween('-7 days'),
|
||||
];
|
||||
}
|
||||
|
||||
public function failed(): static
|
||||
{
|
||||
return $this->state([
|
||||
'status_code' => fake()->randomElement([400, 401, 403, 429, 500, 503]),
|
||||
'error' => fake()->sentence(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user