mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-30 10:38:55 +00:00
988a1c9e9a
This updates balena lint to the latest version to enable eslint support and unblock Typescript updates. This is a huge number of changes as the linting rules are much more strict now, requiring modifiying most files in the codebase. This commit also bumps the test dependency `rewire` as that was interfering with the update of balena-lint Change-type: patch
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import * as path from 'path';
|
|
import { promises as fs } from 'fs';
|
|
import type { SinonStub } from 'sinon';
|
|
import { testfs } from 'mocha-pod';
|
|
|
|
import { expect } from 'chai';
|
|
import Log from '~/lib/supervisor-console';
|
|
import * as network from '~/src/network';
|
|
import * as constants from '~/lib/constants';
|
|
|
|
describe('network', () => {
|
|
it('checks VPN connection status', async () => {
|
|
const vpnStatusPath = path.join(constants.vpnStatusPath, 'active');
|
|
|
|
// Logstub already exists as part of the test hooks
|
|
const logStub = Log.info as SinonStub;
|
|
|
|
// When VPN is inactive vpnStatusPath does not exist
|
|
await expect(
|
|
fs.access(vpnStatusPath),
|
|
'VPN active file does not exist before testing',
|
|
).to.be.rejected;
|
|
await expect(network.isVPNActive()).to.eventually.equal(false);
|
|
expect(logStub.lastCall?.lastArg).to.equal(`VPN connection is not active.`);
|
|
|
|
// Test when VPN is active
|
|
const testFs = await testfs({
|
|
[vpnStatusPath]: '',
|
|
}).enable();
|
|
await expect(network.isVPNActive()).to.eventually.equal(true);
|
|
expect(logStub.lastCall?.lastArg).to.equal(`VPN connection is active.`);
|
|
|
|
// Restore file system
|
|
await testFs.restore();
|
|
});
|
|
});
|