Skip to content

Commit

Permalink
add todo to use AmplifyOutputs config for the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nika Hassani committed Jun 25, 2024
1 parent 835ebfd commit fb3c59c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions packages/api/amplify_api_dart/lib/src/api_plugin_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
_dataConfig?.forEach((key, value) {
// Check the presence of apiKey (not auth type) because other modes might
// have a key if not the primary auth mode.
if (value.apiKey != null ||
value.defaultAuthorizationType == APIAuthorizationType.apiKey ||
if (value.defaultAuthorizationType == APIAuthorizationType.apiKey ||
value.authorizationTypes
.any((element) => element == APIAuthorizationType.apiKey)) {
_authProviderRepo.registerAuthProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void main() {
APIAuthorizationType.iam.authProviderToken,
TestIamAuthProvider(),
);
// TODO(nikahsn): update to use AmplifyOutputs config
final config = AmplifyConfig.fromJson(
jsonDecode(amplifyconfig) as Map<String, Object?>,
);
Expand Down
1 change: 1 addition & 0 deletions packages/api/amplify_api_dart/test/rest_methods_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void main() {
APIAuthorizationType.iam.authProviderToken,
TestIamAuthProvider(),
);
// TODO(nikahsn): update to use AmplifyOutputs config
final config = AmplifyConfig.fromJson(
jsonDecode(amplifyconfig) as Map<String, Object?>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const hostedUiConfig = CognitoOAuthConfig(
signOutRedirectUri: redirectUri,
webDomain: webDomain,
);

// TODO(nikahsn): update to use AmplifyOutputs config
final userPoolOnlyConfig = AmplifyConfig(
auth: AuthConfig.cognito(
userPoolConfig: const CognitoUserPoolConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void main() {
..addInstance<PushNotificationsHostApi>(mockPushNotificationsHostApi)
..addInstance<AmplifySecureStorage>(mockAmplifySecureStorage);

// TODO(nikahsn): update to use AmplifyOutputs config
final config = AmplifyConfig.fromJson(
jsonDecode(amplifyconfig) as Map<String, Object?>,
// ignore: invalid_use_of_internal_member
Expand Down Expand Up @@ -203,6 +204,7 @@ void main() {
group('Config failure cases', () {
test('should throw exception when configuring if there is no appId present',
() async {
// TODO(nikahsn): update to use AmplifyOutputs config
final config = AmplifyConfig.fromJson(
jsonDecode(noPushAppIdAmplifyConfig) as Map<String, Object?>,
// ignore: invalid_use_of_internal_member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import 'dart:async';

import 'package:amplify_core/amplify_core.dart';
import 'package:amplify_core/src/config/amplify_outputs/storage/storage_outputs.dart';
import 'package:amplify_storage_s3/amplify_storage_s3.dart';
import 'package:amplify_storage_s3/src/utils/app_path_provider/app_path_provider.dart';
import 'package:flutter_test/flutter_test.dart';
Expand All @@ -12,17 +13,12 @@ import 'test_utils/test_token_provider.dart';

void main() {
group('AmplifyStorageS3', () {
final testConfig = const AmplifyConfig(
storage: StorageConfig(
plugins: {
S3PluginConfig.pluginKey: S3PluginConfig(
bucket: '123',
region: 'west-2',
),
},
),
// ignore: invalid_use_of_internal_member
).toAmplifyOutputs();
// ignore: invalid_use_of_internal_member
const testConfig = AmplifyOutputs(
version: '1',
storage: StorageOutputs(bucketName: '123', awsRegion: 'west-2'),
);
// ignore: invalid_use_of_internal_member
final testAuthProviderRepo = AmplifyAuthProviderRepository()
..registerAuthProvider(
APIAuthorizationType.userPools.authProviderToken,
Expand Down

0 comments on commit fb3c59c

Please sign in to comment.