Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Oct 15, 2024
1 parent 4e5cc32 commit e6f0382
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/core/test/InstanceSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,19 @@ describe('InstanceSettings', () => {
);
});
});

describe('constructor', () => {
it('should generate a `hostId`', () => {
const encryptionKey = 'test_key';
process.env.N8N_ENCRYPTION_KEY = encryptionKey;
jest.spyOn(fs, 'existsSync').mockReturnValueOnce(true);
jest.spyOn(fs, 'readFileSync').mockReturnValueOnce(JSON.stringify({ encryptionKey }));

const settings = new InstanceSettings();

const [instanceType, nanoid] = settings.hostId.split('-');
expect(instanceType).toEqual('main');
expect(nanoid).toHaveLength(16); // e.g. sDX6ZPc0bozv66zM
});
});
});

0 comments on commit e6f0382

Please sign in to comment.