Skip to content

Commit

Permalink
chore: add AWSSerializable and added comment to test to address Futur…
Browse files Browse the repository at this point in the history
…e.delayed
  • Loading branch information
khatruong2009 committed Sep 19, 2023
1 parent 5f185c4 commit b77c8ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CloudWatchLoggerPluginConfiguration with AWSDebuggable {
/// The logging constraint for sending logs to CloudWatch.
/// {@endtemplate}
@zAmplifySerializable
class LoggingConstraint with AWSDebuggable {
class LoggingConstraint with AWSDebuggable, AWSSerializable {
/// {@macro aws_logging_cloudwatch.logging_constraint}
const LoggingConstraint({
this.defaultLogLevel = LogLevel.error,
Expand All @@ -63,6 +63,7 @@ class LoggingConstraint with AWSDebuggable {
_$LoggingConstraintFromJson(json);

/// Converts an [LoggingConstraint] instance to a [Map].
@override
Map<String, dynamic> toJson() => _$LoggingConstraintToJson(this);

/// The default [LogLevel] for sending logs to CloudWatch.
Expand All @@ -80,7 +81,7 @@ class LoggingConstraint with AWSDebuggable {

/// The logging constraint for user specific log level.
@zAmplifySerializable
class UserLogLevel {
class UserLogLevel with AWSDebuggable, AWSSerializable {
/// The logging constraint for user specific log level.
const UserLogLevel({
this.defaultLogLevel,
Expand All @@ -92,11 +93,15 @@ class UserLogLevel {
_$UserLogLevelFromJson(json);

/// Converts a [UserLogLevel] instance to a [Map].
@override
Map<String, dynamic> toJson() => _$UserLogLevelToJson(this);

/// The default [LogLevel] for sending logs to CloudWatch.
final LogLevel? defaultLogLevel;

/// The [LogLevel] for different categories.
final Map<String, LogLevel>? categoryLogLevel;

@override
String get runtimeTypeName => 'UserLogLevel';
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void main() {

await provider.ready;

// Verify that _loggingConstraint uses local storage
// Verify that _loggingConstraint uses local storage
expect(
provider.loggingConstraint!.toJson(),
equals(json.decode(sampleJson)),
Expand Down Expand Up @@ -190,11 +190,12 @@ void main() {
awsHttpClient: mockAWSHttpClient,
);

// Wait for the provider to refresh the constraints and make the second call to the endpoint
await Future<void>.delayed(const Duration(seconds: 2));

await provider.ready;

// Verify that _loggingConstraint got updated
// Verify that _loggingConstraint got updated
expect(
provider.loggingConstraint!.toJson(),
equals(json.decode(updatedJson)),
Expand Down Expand Up @@ -225,7 +226,7 @@ void main() {

await provider.ready;

// Verify that _loggingConstraint is set
// Verify that _loggingConstraint is set
expect(provider.loggingConstraint, equals(null));
});
});
Expand Down

0 comments on commit b77c8ae

Please sign in to comment.