Skip to content

Commit

Permalink
Merge pull request #32 from ECFMP/flakey-test-fix
Browse files Browse the repository at this point in the history
chore: fix flakey test and use refreshdatabase
  • Loading branch information
AndyTWF authored May 8, 2022
2 parents f13383a + 72514c1 commit 4511874
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 1 addition & 2 deletions database/factories/DiscordTagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Models\DiscordTag;
use Illuminate\Database\Eloquent\Factories\Factory;
use Str;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DiscordTag>
Expand All @@ -21,7 +20,7 @@ class DiscordTagFactory extends Factory
public function definition()
{
return [
'tag' => sprintf('@%s', $this->faker->unique()->word()),
'tag' => sprintf('@%s', $this->faker->unique()->numberBetween(0, PHP_INT_MAX)),
'description' => $this->faker->sentence(4),
];
}
Expand Down
16 changes: 15 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@

namespace Tests;

use DB;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use CreatesApplication, RefreshDatabase;

public function beforeRefreshingDatabase()
{
DB::table('discord_notifications')->delete();
DB::table('flow_measures')->delete();
DB::table('events')->delete();
DB::table('flight_information_regions')->delete();
DB::table('users')->delete();
DB::table('airport_groups')->delete();
DB::table('airports')->delete();
DB::table('discord_tags')->delete();
}
}

0 comments on commit 4511874

Please sign in to comment.