feat: retry get gps coordinate when rate limited second (#5615)
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Unit\Services\Instance\Geolocalization;
|
||||
use Tests\TestCase;
|
||||
use App\Models\Account\Place;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Exceptions\RateLimitedSecondException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use App\Services\Instance\Geolocalization\GetGPSCoordinate;
|
||||
@@ -97,7 +98,32 @@ class GetGPSCoordinateTest extends TestCase
|
||||
|
||||
$this->expectException(ValidationException::class);
|
||||
|
||||
$geocodingService = new GetGPSCoordinate;
|
||||
$place = app(GetGPSCoordinate::class)->execute($request);
|
||||
app(GetGPSCoordinate::class)->execute($request);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_release_the_job_if_rate_limited_second()
|
||||
{
|
||||
config(['monica.enable_geolocation' => true]);
|
||||
config(['monica.location_iq_api_key' => 'test']);
|
||||
|
||||
Http::fake([
|
||||
'us1.locationiq.com/v1/*' => Http::response('{"error":"Rate Limited Second"}', 429),
|
||||
]);
|
||||
|
||||
$place = factory(Place::class)->create([
|
||||
'country' => 'ewqr',
|
||||
'street' => '',
|
||||
'city' => 'sieklopekznqqq',
|
||||
'postal_code' => '',
|
||||
]);
|
||||
|
||||
$request = [
|
||||
'account_id' => $place->account_id,
|
||||
'place_id' => $place->id,
|
||||
];
|
||||
|
||||
$this->expectException(RateLimitedSecondException::class);
|
||||
app(GetGPSCoordinate::class)->execute($request);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user