mattermost-mobile-upstream/app/utils/database_errors.test.ts
Daniel Espino García 41c1300435
[MM-68315] Add autorecovery for database corruptions (#9900)
* [MM-68315] Add autorecovery for database corruptions

* Address feedback
2026-07-13 18:02:35 +02:00

18 lines
893 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {isDatabaseCorruptionError} from './database_errors';
describe('database_errors', () => {
test('isDatabaseCorruptionError detects malformed database errors', () => {
expect(isDatabaseCorruptionError(new Error('database disk image is malformed'))).toBe(true);
expect(isDatabaseCorruptionError(new Error('SqliteError: database disk image is malformed (code: 11)'))).toBe(true);
});
test('isDatabaseCorruptionError ignores unrelated errors', () => {
expect(isDatabaseCorruptionError(new Error('database is locked'))).toBe(false);
expect(isDatabaseCorruptionError(new Error('network request failed'))).toBe(false);
expect(isDatabaseCorruptionError('SQLITE_CORRUPT: database corruption at line 1')).toBe(false);
});
});