52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { buildGatewayVersionInfo, buildVersionInfo } from '../../src/server/version.js';
|
|
import { HARBOR_VERSIONS, versionCompatibility } from '../../src/shared/versions.js';
|
|
|
|
test('component versions enforce one Harbor major and one Gateway major.minor', () => {
|
|
assert.deepEqual(versionCompatibility(HARBOR_VERSIONS), {
|
|
compatible: true,
|
|
major: true,
|
|
gateway: true,
|
|
});
|
|
assert.equal(versionCompatibility({
|
|
macClient: '1.9.4',
|
|
gatewayClient: '1.3.1',
|
|
gatewayBackend: '1.3.8',
|
|
}).compatible, true);
|
|
assert.equal(versionCompatibility({
|
|
macClient: '1.0.0',
|
|
gatewayClient: '1.3.0',
|
|
gatewayBackend: '1.4.0',
|
|
}).compatible, false);
|
|
});
|
|
|
|
test('gateway reports control backend and deployed dataplane separately', () => {
|
|
const control = {
|
|
apiVersion: 1,
|
|
location: 'gateway',
|
|
components: { gatewayBackend: '0.4.0' },
|
|
runtime: { singBox: '1.12.13' },
|
|
};
|
|
assert.deepEqual(buildGatewayVersionInfo(control, {
|
|
gatewayBackendVersion: '0.3.0',
|
|
singBoxVersion: '1.12.13',
|
|
}), {
|
|
apiVersion: 1,
|
|
location: 'gateway',
|
|
components: { gatewayBackend: '0.4.0' },
|
|
runtime: { dataplaneVersion: '0.3.0', singBox: '1.12.13' },
|
|
});
|
|
});
|
|
|
|
test('runtime version info reports the installed sing-box binary', () => {
|
|
const run = () => ({ stdout: 'sing-box version 1.12.13\n', stderr: '' });
|
|
assert.deepEqual(buildVersionInfo('gateway', run), {
|
|
apiVersion: 1,
|
|
location: 'gateway',
|
|
components: { gatewayBackend: HARBOR_VERSIONS.gatewayBackend },
|
|
runtime: { singBox: '1.12.13' },
|
|
});
|
|
});
|