62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
|
|
|
import { CloudlyAppStoreManager } from '../ts/manager.appstore/classes.appstoremanager.js';
|
|
|
|
const createManager = () => Object.create(CloudlyAppStoreManager.prototype) as any;
|
|
|
|
tap.test('should preserve service volume overrides during App Store upgrades', async () => {
|
|
const manager = createManager();
|
|
const volumes = manager.mergeUpgradeVolumes(
|
|
[
|
|
{ mountPath: '/data', name: 'custom-data', driver: 'local' },
|
|
{ mountPath: '/cache', name: 'custom-cache' },
|
|
],
|
|
[
|
|
'/data',
|
|
{ mountPath: '/config', readOnly: true },
|
|
],
|
|
);
|
|
|
|
expect(volumes).toEqual([
|
|
{ mountPath: '/data', name: 'custom-data', driver: 'local' },
|
|
{ mountPath: '/config', readOnly: true },
|
|
{ mountPath: '/cache', name: 'custom-cache' },
|
|
]);
|
|
});
|
|
|
|
tap.test('should preserve service published port overrides during App Store upgrades', async () => {
|
|
const manager = createManager();
|
|
const publishedPorts = manager.mergeUpgradePublishedPorts(
|
|
[
|
|
{ targetPort: 5432, publishedPort: 15432, protocol: 'tcp' },
|
|
{ targetPort: 9999, publishedPort: 19999 },
|
|
],
|
|
[
|
|
{ targetPort: 5432, publishedPort: 5432 },
|
|
{ targetPort: 6379 },
|
|
],
|
|
);
|
|
|
|
expect(publishedPorts).toEqual([
|
|
{ targetPort: 5432, publishedPort: 15432, protocol: 'tcp' },
|
|
{ targetPort: 6379, protocol: 'tcp' },
|
|
{ targetPort: 9999, publishedPort: 19999, protocol: 'tcp' },
|
|
]);
|
|
});
|
|
|
|
tap.test('should report unsupported App Store published port configs', async () => {
|
|
const manager = createManager();
|
|
const unsupported = manager.getUnsupportedPublishedPorts([
|
|
{ targetPort: 80, publishedPort: 80 },
|
|
{ targetPort: 81, publishedPort: 80 },
|
|
{ targetPort: 82, publishedPort: 82, hostIp: '127.0.0.1' },
|
|
{ targetPort: 9000, targetPortEnd: 9001, publishedPort: 19000, publishedPortEnd: 19002 },
|
|
]);
|
|
|
|
expect(unsupported.some((messageArg: string) => messageArg.includes('duplicates published port 80/tcp'))).toBeTrue();
|
|
expect(unsupported.some((messageArg: string) => messageArg.includes('unsupported hostIp'))).toBeTrue();
|
|
expect(unsupported.some((messageArg: string) => messageArg.includes('mismatched target and published port ranges'))).toBeTrue();
|
|
});
|
|
|
|
export default tap.start();
|