@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
57 lines • 2.44 kB
JavaScript
// SPDX-License-Identifier: Apache-2.0
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { platform, arch } from 'node:os';
import { existsSync } from 'node:fs';
import { execSync } from 'node:child_process';
import { HelmSoftwareLoader } from '../../../../../src/integration/helm/resource/helm-software-loader.js';
import { OperatingSystem } from '../../../../../src/business/utils/operating-system.js';
import { SemanticVersion } from '../../../../../src/business/utils/semantic-version.js';
describe('Helm Software Loader Test', () => {
const currentPlatform = platform();
const currentArch = arch();
const supportedPlatforms = {
linux: ['x64', 'arm64'],
darwin: ['x64', 'arm64'],
win32: ['x64'],
};
const installHelmAndVerify = async () => {
const helmPath = await HelmSoftwareLoader.getHelmExecutablePath();
expect(helmPath).to.not.be.null;
expect(existsSync(helmPath)).to.be.true;
// Check if file is executable
try {
execSync(`test -x "${helmPath}"`, { stdio: 'ignore' });
}
catch {
expect.fail('Helm executable should be executable');
}
// Check filename
const expectedFilename = OperatingSystem.isWin32() ? 'helm.exe' : 'helm';
expect(helmPath.endsWith(expectedFilename)).to.be.true;
// Check version
let helmVersion;
try {
helmVersion = execSync(`"${helmPath}" version --short`, { encoding: 'utf8' }).trim();
}
catch {
expect.fail('Failed to execute helm version command');
}
expect(helmVersion).to.not.be.empty;
if (helmVersion.toLowerCase().startsWith('v')) {
helmVersion = helmVersion.slice(1);
}
const actualVersion = new SemanticVersion(helmVersion);
const minimumVersion = new SemanticVersion('3.12.0');
expect(actualVersion).to.not.be.null;
expect(actualVersion.greaterThanOrEqual(minimumVersion.toString())).to.be.true;
};
// Run tests only if current platform/arch is supported
if (currentPlatform in supportedPlatforms &&
supportedPlatforms[currentPlatform].includes(currentArch)) {
it(`${currentPlatform}: Install Supported Helm Version`, async () => {
await installHelmAndVerify();
});
}
});
//# sourceMappingURL=helm-software-loader.test.js.map