36 lines
1.2 KiB
Dart
36 lines
1.2 KiB
Dart
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:marianum_mobile/storage/keychain_write.dart';
|
|
|
|
void main() {
|
|
group('isKeychainDuplicateItem', () {
|
|
test('recognises the OSStatus in the details', () {
|
|
final e = PlatformException(
|
|
code: 'Unexpected security result code',
|
|
message:
|
|
'Code: -25299, Message: The specified item already exists in the keychain.',
|
|
details: -25299,
|
|
);
|
|
expect(isKeychainDuplicateItem(e), isTrue);
|
|
});
|
|
|
|
test('falls back to the message when details are missing', () {
|
|
final e = PlatformException(
|
|
code: 'Unexpected security result code',
|
|
message: 'Code: -25299, Message: duplicate',
|
|
);
|
|
expect(isKeychainDuplicateItem(e), isTrue);
|
|
});
|
|
|
|
test('ignores other keychain errors and non-platform errors', () {
|
|
final e = PlatformException(
|
|
code: 'Unexpected security result code',
|
|
message: 'Code: -25308, Message: interaction not allowed',
|
|
details: -25308,
|
|
);
|
|
expect(isKeychainDuplicateItem(e), isFalse);
|
|
expect(isKeychainDuplicateItem(StateError('x')), isFalse);
|
|
});
|
|
});
|
|
}
|