Skip to content

Commit c3dddff

Browse files
authored
Merge pull request #236 from atsign-foundation/exception_stack_test
test: Exception stack test
2 parents 1390a35 + 9761a95 commit c3dddff

File tree

1 file changed

+59
-5
lines changed

1 file changed

+59
-5
lines changed

at_commons/test/at_exception_stack_test.dart

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ void main() {
1414
startsWith('Failed to syncData caused by'));
1515
});
1616

17-
test('chained exception list size is zero', () {
18-
final exceptionStack = AtExceptionStack();
19-
expect(exceptionStack.getTraceMessage(), isEmpty);
20-
});
21-
2217
test('check intent message', () {
2318
final atChainedException = AtChainedException(
2419
Intent.syncData, ExceptionScenario.invalidKeyFormed, 'sync issue');
@@ -28,5 +23,64 @@ void main() {
2823
expect(exceptionStack.getIntentMessage(Intent.syncData),
2924
equals('Failed to syncData'));
3025
});
26+
27+
test('chained exception list size is zero', () {
28+
final exceptionStack = AtExceptionStack();
29+
expect(exceptionStack.getTraceMessage(), isEmpty);
30+
});
31+
32+
test('no namespace provided - check trace message', () {
33+
final atChainedException = AtChainedException(Intent.validateKey,
34+
ExceptionScenario.noNamespaceProvided, 'name space is not provided');
35+
final exceptionStack = AtExceptionStack();
36+
exceptionStack.add(atChainedException);
37+
expect(exceptionStack.getTraceMessage(), isNotEmpty);
38+
expect(exceptionStack.getTraceMessage(),
39+
startsWith('Failed to validateKey caused by'));
40+
});
41+
42+
test('atsign does not exist - check trace message', () {
43+
final atChainedException = AtChainedException(Intent.shareData,
44+
ExceptionScenario.atSignDoesNotExist, 'atsign does not exist');
45+
final exceptionStack = AtExceptionStack();
46+
exceptionStack.add(atChainedException);
47+
expect(exceptionStack.getTraceMessage(), isNotEmpty);
48+
expect(exceptionStack.getTraceMessage(),
49+
startsWith('Failed to shareData caused by'));
50+
});
51+
52+
test('Decryption failed - check trace message', () {
53+
final atChainedException = AtChainedException(Intent.decryptData,
54+
ExceptionScenario.decryptionFailed, 'Decryption failed');
55+
final exceptionStack = AtExceptionStack();
56+
exceptionStack.add(atChainedException);
57+
expect(exceptionStack.getTraceMessage(), isNotEmpty);
58+
expect(exceptionStack.getTraceMessage(),
59+
startsWith('Failed to decryptData caused by'));
60+
});
61+
62+
test('Encryption private key not found - check trace message', () {
63+
final atChainedException = AtChainedException(
64+
Intent.fetchEncryptionPrivateKey,
65+
ExceptionScenario.fetchEncryptionKeys,
66+
'Encryption keys not found');
67+
final exceptionStack = AtExceptionStack();
68+
exceptionStack.add(atChainedException);
69+
expect(exceptionStack.getTraceMessage(), isNotEmpty);
70+
expect(exceptionStack.getTraceMessage(),
71+
startsWith('Failed to fetchEncryptionPrivateKey caused by'));
72+
});
73+
74+
test('Notification failed - check trace message', () {
75+
final atChainedException = AtChainedException(
76+
Intent.notifyData,
77+
ExceptionScenario.secondaryServerNotReachable,
78+
'Secondary server not reachable');
79+
final exceptionStack = AtExceptionStack();
80+
exceptionStack.add(atChainedException);
81+
expect(exceptionStack.getTraceMessage(), isNotEmpty);
82+
expect(exceptionStack.getTraceMessage(),
83+
startsWith('Failed to notifyData caused by'));
84+
});
3185
});
3286
}

0 commit comments

Comments
 (0)