Fix crash when saving state.json fails. #4388

This commit is contained in:
Koen Kanters committed 2020-09-19 10:59:12 +02:00
1 parent 4f9c36ee44
commit 7fe3167e97
3 files changed
+15 -2

No files matched your search

+9
View File
@@ -551,6 +551,15 @@ describe('Controller', () => {
expect(data.stateExists()).toBeFalsy();
});
it('Shouldnt crash when it cannot save state', async () => {
data.removeState();
await controller.start();
logger.error.mockClear();
controller.state.file = "/";
await controller.state.save();
expect(logger.error).toHaveBeenCalledWith(`Failed to write state to '/' (EISDIR: illegal operation on a directory, open '/')`);
});
it('Publish should not cache when set', async () => {
settings.set(['advanced', 'cache_state'], false);
data.writeEmptyState();