Skip to content

Commit

Permalink
fixed PushToken TTL_MINUTES validation
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmer committed Dec 9, 2024
1 parent 98ab966 commit 4a9621c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
5 changes: 1 addition & 4 deletions lib/model/tokens/push_token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ class PushToken extends Token {
Token.ISSUER: const ObjectValidatorNullable<String>(defaultValue: ''),
Token.SERIAL: const ObjectValidator<String>(),
SSL_VERIFY: boolValidator.withDefault(true),
TTL_MINUTES: ObjectValidator<Duration>(
transformer: (v) => Duration(minutes: int.parse(v)),
defaultValue: const Duration(minutes: 10),
),
TTL_MINUTES: intValidatorNullable,
ENROLLMENT_CREDENTIAL: const ObjectValidatorNullable<String>(),
ROLLOUT_URL: stringToUrivalidator,
Token.IMAGE: stringToUriValidatorNullable,
Expand Down
30 changes: 28 additions & 2 deletions test/unit_test/model/processor_result_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,41 @@ void _testProcessorResult() {
});
group('factories', () {
test('success', () {
ProcessorResult<String> result = const ProcessorResult.success('data');
const ProcessorResult<String> result = ProcessorResult.success('data');
expect(result, isA<ProcessorResultSuccess>());
expect((result as ProcessorResultSuccess).resultData, 'data');
});
test('error', () {
const result = ProcessorResult.failed('error');
const ProcessorResult<String> result = ProcessorResult.failed('error');
expect(result, isA<ProcessorResultFailed>());
expect((result as ProcessorResultFailed).message, 'error');
});
});

group('is', () {
test('success', () {
const ProcessorResult<String> result = ProcessorResultSuccess('data');
expect(result.isSuccess, isTrue);
expect(result.isFailed, isFalse);
});
test('error', () {
const ProcessorResult<String> result = ProcessorResultFailed('error');
expect(result.isSuccess, isFalse);
expect(result.isFailed, isTrue);
});
});

group('as', () {
test('success', () {
const ProcessorResult<String> result = ProcessorResultSuccess('data');
expect(result.asSuccess, 'data');
expect(() => result.asFailed, throwsA(isA<AssertionError>()));
});
test('error', () {
const ProcessorResult<String> result = ProcessorResultFailed('error');
expect(result.asFailed, 'error');
expect(() => result.asSuccess, throwsA(isA<AssertionError>()));
});
});
});
}

0 comments on commit 4a9621c

Please sign in to comment.