-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix test names & clean up tests - changed tests to generate nice mocks - add test util for matching against a request's auth header - remove the need for GetIt mocking in retry_authenticator_test - changed throttler extension to return task instead of future - add withMinimumDuration extension method on Task - add getAuthenticationToken method in repository - refactor AuthenticationInterceptor.onRequest - hugely simplify RetryAuthenticator - add withBearerToken extension method on Request - rename repository.dart to repository_test.dart
- Loading branch information
Showing
15 changed files
with
314 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:fpdart/fpdart.dart'; | ||
|
||
extension TaskX<A> on Task<A> { | ||
/// Ensure that this task takes at least [duration] to complete. | ||
/// | ||
/// If the task completes before [duration], the returned task will | ||
/// wait for the remaining time before returning the result. | ||
Task<A> withMinimumDuration(Duration duration) => Task(() async { | ||
final minimumDurationTask = Future.delayed(duration); | ||
final result = await run(); | ||
await minimumDurationTask; | ||
return result; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export 'bloc/authentication_cubit.dart'; | ||
export 'http_utils/authentication_interceptor.dart'; | ||
export 'http_utils/retry_authenticator.dart'; | ||
export 'http_utils/with_bearer_token.dart'; | ||
export 'models/authentication_info.dart'; | ||
export 'repository.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:chopper/chopper.dart'; | ||
|
||
extension RequestX on Request { | ||
/// Returns a copy of this [Request] with the given [token] added to the | ||
/// `Authorization` header. | ||
Request withBearerToken(String token) => | ||
this..headers['Authorization'] = 'Bearer $token'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.