feat: change disk in tests
This commit is contained in:
parent
64b01dc855
commit
9ee45210ba
|
|
@ -11,14 +11,16 @@ use Laravel\Sanctum\Sanctum;
|
||||||
uses(RefreshDatabase::class);
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
it('deletes the authenticated account and related data', function () {
|
it('deletes the authenticated account and related data', function () {
|
||||||
Storage::fake('public');
|
config()->set('filesystems.default', 's3');
|
||||||
|
|
||||||
|
Storage::fake('s3');
|
||||||
|
|
||||||
$user = User::factory()->create([
|
$user = User::factory()->create([
|
||||||
'avatar_url' => 'avatars/profile.jpg',
|
'avatar_url' => 'avatars/profile.jpg',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Storage::disk('public')->put('avatars/profile.jpg', 'avatar');
|
Storage::disk('s3')->put('avatars/profile.jpg', 'avatar');
|
||||||
Storage::disk('public')->put('meal-posts/local.jpg', 'meal');
|
Storage::disk('s3')->put('meal-posts/local.jpg', 'meal');
|
||||||
|
|
||||||
$localMealPost = MealPosts::factory()->for($user, 'user')->create([
|
$localMealPost = MealPosts::factory()->for($user, 'user')->create([
|
||||||
'image_url' => 'meal-posts/local.jpg',
|
'image_url' => 'meal-posts/local.jpg',
|
||||||
|
|
@ -71,8 +73,8 @@ it('deletes the authenticated account and related data', function () {
|
||||||
$this->assertDatabaseMissing('sessions', ['user_id' => $user->getKey()]);
|
$this->assertDatabaseMissing('sessions', ['user_id' => $user->getKey()]);
|
||||||
$this->assertDatabaseMissing('password_reset_tokens', ['email' => $user->email]);
|
$this->assertDatabaseMissing('password_reset_tokens', ['email' => $user->email]);
|
||||||
|
|
||||||
Storage::disk('public')->assertMissing('avatars/profile.jpg');
|
Storage::disk('s3')->assertMissing('avatars/profile.jpg');
|
||||||
Storage::disk('public')->assertMissing('meal-posts/local.jpg');
|
Storage::disk('s3')->assertMissing('meal-posts/local.jpg');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires authentication to delete an account', function () {
|
it('requires authentication to delete an account', function () {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ use Laravel\Ai\Image;
|
||||||
uses(RefreshDatabase::class);
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
it('generates an ai meal post with an image', function () {
|
it('generates an ai meal post with an image', function () {
|
||||||
Storage::fake('public');
|
config()->set('filesystems.default', 's3');
|
||||||
|
|
||||||
|
Storage::fake('s3');
|
||||||
|
|
||||||
config()->set('meal_posts.ai_generation.user_name', 'Chef IA');
|
config()->set('meal_posts.ai_generation.user_name', 'Chef IA');
|
||||||
config()->set('meal_posts.ai_generation.user_email', 'chef-ia@example.test');
|
config()->set('meal_posts.ai_generation.user_email', 'chef-ia@example.test');
|
||||||
|
|
@ -100,7 +102,7 @@ it('generates an ai meal post with an image', function () {
|
||||||
->and($mealPost->ingredients[0]->ingredient)->toBe('Riz vinaigre');
|
->and($mealPost->ingredients[0]->ingredient)->toBe('Riz vinaigre');
|
||||||
|
|
||||||
expect($mealPost->image_url)->toStartWith('meal-posts/ai-generated/');
|
expect($mealPost->image_url)->toStartWith('meal-posts/ai-generated/');
|
||||||
Storage::disk('public')->assertExists($mealPost->image_url);
|
Storage::disk('s3')->assertExists($mealPost->image_url);
|
||||||
|
|
||||||
$this->assertDatabaseHas('meal_posts', [
|
$this->assertDatabaseHas('meal_posts', [
|
||||||
'id' => $mealPost->id,
|
'id' => $mealPost->id,
|
||||||
|
|
@ -159,7 +161,9 @@ it('generates an ai meal post with an image', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('records a failed ai meal post generation attempt', function () {
|
it('records a failed ai meal post generation attempt', function () {
|
||||||
Storage::fake('public');
|
config()->set('filesystems.default', 's3');
|
||||||
|
|
||||||
|
Storage::fake('s3');
|
||||||
Exceptions::fake();
|
Exceptions::fake();
|
||||||
|
|
||||||
config()->set('meal_posts.ai_generation.user_name', 'Chef IA');
|
config()->set('meal_posts.ai_generation.user_name', 'Chef IA');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue