Skip to content

Commit

Permalink
Merge pull request #236 from atsign-foundation/exception_stack_test
Browse files Browse the repository at this point in the history
test: Exception stack test
  • Loading branch information
murali-shris authored Oct 19, 2022
2 parents 1390a35 + 9761a95 commit c3dddff
Showing 1 changed file with 59 additions and 5 deletions.
64 changes: 59 additions & 5 deletions at_commons/test/at_exception_stack_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ void main() {
startsWith('Failed to syncData caused by'));
});

test('chained exception list size is zero', () {
final exceptionStack = AtExceptionStack();
expect(exceptionStack.getTraceMessage(), isEmpty);
});

test('check intent message', () {
final atChainedException = AtChainedException(
Intent.syncData, ExceptionScenario.invalidKeyFormed, 'sync issue');
Expand All @@ -28,5 +23,64 @@ void main() {
expect(exceptionStack.getIntentMessage(Intent.syncData),
equals('Failed to syncData'));
});

test('chained exception list size is zero', () {
final exceptionStack = AtExceptionStack();
expect(exceptionStack.getTraceMessage(), isEmpty);
});

test('no namespace provided - check trace message', () {
final atChainedException = AtChainedException(Intent.validateKey,
ExceptionScenario.noNamespaceProvided, 'name space is not provided');
final exceptionStack = AtExceptionStack();
exceptionStack.add(atChainedException);
expect(exceptionStack.getTraceMessage(), isNotEmpty);
expect(exceptionStack.getTraceMessage(),
startsWith('Failed to validateKey caused by'));
});

test('atsign does not exist - check trace message', () {
final atChainedException = AtChainedException(Intent.shareData,
ExceptionScenario.atSignDoesNotExist, 'atsign does not exist');
final exceptionStack = AtExceptionStack();
exceptionStack.add(atChainedException);
expect(exceptionStack.getTraceMessage(), isNotEmpty);
expect(exceptionStack.getTraceMessage(),
startsWith('Failed to shareData caused by'));
});

test('Decryption failed - check trace message', () {
final atChainedException = AtChainedException(Intent.decryptData,
ExceptionScenario.decryptionFailed, 'Decryption failed');
final exceptionStack = AtExceptionStack();
exceptionStack.add(atChainedException);
expect(exceptionStack.getTraceMessage(), isNotEmpty);
expect(exceptionStack.getTraceMessage(),
startsWith('Failed to decryptData caused by'));
});

test('Encryption private key not found - check trace message', () {
final atChainedException = AtChainedException(
Intent.fetchEncryptionPrivateKey,
ExceptionScenario.fetchEncryptionKeys,
'Encryption keys not found');
final exceptionStack = AtExceptionStack();
exceptionStack.add(atChainedException);
expect(exceptionStack.getTraceMessage(), isNotEmpty);
expect(exceptionStack.getTraceMessage(),
startsWith('Failed to fetchEncryptionPrivateKey caused by'));
});

test('Notification failed - check trace message', () {
final atChainedException = AtChainedException(
Intent.notifyData,
ExceptionScenario.secondaryServerNotReachable,
'Secondary server not reachable');
final exceptionStack = AtExceptionStack();
exceptionStack.add(atChainedException);
expect(exceptionStack.getTraceMessage(), isNotEmpty);
expect(exceptionStack.getTraceMessage(),
startsWith('Failed to notifyData caused by'));
});
});
}

0 comments on commit c3dddff

Please sign in to comment.