From aedfd31dd0ed420f80e5542f301eaa3f8a81b28f Mon Sep 17 00:00:00 2001 From: Felipe Lalanne <1822826+pipex@users.noreply.github.com> Date: Tue, 7 Mar 2023 21:55:52 -0300 Subject: [PATCH] Remove release and image id from test services --- .../compose/application-manager.spec.ts | 215 +++++++++++------- test/lib/state-helper.ts | 9 +- 2 files changed, 139 insertions(+), 85 deletions(-) diff --git a/test/integration/compose/application-manager.spec.ts b/test/integration/compose/application-manager.spec.ts index 7683a0049..bc63a4d0f 100644 --- a/test/integration/compose/application-manager.spec.ts +++ b/test/integration/compose/application-manager.spec.ts @@ -398,23 +398,31 @@ describe('compose/application-manager', () => { const targetApps = createApps( { services: [ - await createService({ - image: 'main-image', - appId: 1, - appUuid: 'appuuid', - commit: 'new-release', - serviceName: 'main', - composition: { - depends_on: ['dep'], + await createService( + { + image: 'main-image', + appId: 1, + appUuid: 'appuuid', + commit: 'new-release', + serviceName: 'main', + composition: { + depends_on: ['dep'], + }, }, - }), - await createService({ - image: 'dep-image', - appId: 1, - appUuid: 'appuuid', - commit: 'new-release', - serviceName: 'dep', - }), + {}, + true, + ), + await createService( + { + image: 'dep-image', + appId: 1, + appUuid: 'appuuid', + commit: 'new-release', + serviceName: 'dep', + }, + {}, + true, + ), ], networks: [DEFAULT_NETWORK], }, @@ -487,19 +495,27 @@ describe('compose/application-manager', () => { const targetApps = createApps( { services: [ - await createService({ - image: 'main-image', - serviceName: 'main', - commit: 'new-release', - composition: { - depends_on: ['dep'], + await createService( + { + image: 'main-image', + serviceName: 'main', + commit: 'new-release', + composition: { + depends_on: ['dep'], + }, }, - }), - await createService({ - image: 'dep-image', - serviceName: 'dep', - commit: 'new-release', - }), + {}, + true, + ), + await createService( + { + image: 'dep-image', + serviceName: 'dep', + commit: 'new-release', + }, + {}, + true, + ), ], networks: [DEFAULT_NETWORK], }, @@ -549,19 +565,27 @@ describe('compose/application-manager', () => { const targetApps = createApps( { services: [ - await createService({ - image: 'main-image', - serviceName: 'main', - commit: 'new-release', - composition: { - depends_on: ['dep'], + await createService( + { + image: 'main-image', + serviceName: 'main', + commit: 'new-release', + composition: { + depends_on: ['dep'], + }, }, - }), - await createService({ - image: 'dep-image', - serviceName: 'dep', - commit: 'new-release', - }), + {}, + true, + ), + await createService( + { + image: 'dep-image', + serviceName: 'dep', + commit: 'new-release', + }, + {}, + true, + ), ], networks: [DEFAULT_NETWORK], }, @@ -615,7 +639,7 @@ describe('compose/application-manager', () => { it('infers to remove spurious containers', async () => { const targetApps = createApps( { - services: [await createService({ image: 'main-image' })], + services: [await createService({ image: 'main-image' }, {}, true)], networks: [DEFAULT_NETWORK], }, true, @@ -853,6 +877,7 @@ describe('compose/application-manager', () => { { image: 'main-image' }, // Target has a matching image already { options: { imageInfo: { Id: 'sha256:bbbb' } } }, + true, ), ], networks: [DEFAULT_NETWORK], @@ -1091,20 +1116,28 @@ describe('compose/application-manager', () => { const targetApps = createApps( { services: [ - await createService({ - running: true, - image: 'main-image-1', - appId: 1, - appUuid: 'app-one', - commit: 'commit-for-app-1', - }), - await createService({ - running: true, - image: 'main-image-2', - appId: 2, - appUuid: 'app-two', - commit: 'commit-for-app-2', - }), + await createService( + { + running: true, + image: 'main-image-1', + appId: 1, + appUuid: 'app-one', + commit: 'commit-for-app-1', + }, + {}, + true, + ), + await createService( + { + running: true, + image: 'main-image-2', + appId: 2, + appUuid: 'app-two', + commit: 'commit-for-app-2', + }, + {}, + true, + ), ], networks: [ // Default networks for two apps @@ -1523,38 +1556,54 @@ describe('compose/application-manager', () => { targetApps = createApps( { services: [ - await createService({ - image: 'test-image', - serviceName: 'one', - running: true, - composition: { - restart: 'always', + await createService( + { + image: 'test-image', + serviceName: 'one', + running: true, + composition: { + restart: 'always', + }, }, - }), - await createService({ - image: 'test-image', - serviceName: 'two', - running: true, - composition: { - restart: 'unless-stopped', + {}, + true, + ), + await createService( + { + image: 'test-image', + serviceName: 'two', + running: true, + composition: { + restart: 'unless-stopped', + }, }, - }), - await createService({ - image: 'test-image', - serviceName: 'three', - running: true, - composition: { - restart: 'on-failure', + {}, + true, + ), + await createService( + { + image: 'test-image', + serviceName: 'three', + running: true, + composition: { + restart: 'on-failure', + }, }, - }), - await createService({ - image: 'test-image', - serviceName: 'four', - running: true, - composition: { - restart: 'no', + {}, + true, + ), + await createService( + { + image: 'test-image', + serviceName: 'four', + running: true, + composition: { + restart: 'no', + }, }, - }), + {}, + true, + ), ], networks: [DEFAULT_NETWORK], }, diff --git a/test/lib/state-helper.ts b/test/lib/state-helper.ts index 69fa62887..bff77b325 100644 --- a/test/lib/state-helper.ts +++ b/test/lib/state-helper.ts @@ -23,6 +23,7 @@ export async function createService( ...conf } = {} as Partial, { state = {} as Partial, options = {} as any } = {}, + isTarget = false, ) { const svc = await Service.fromComposeObject( { @@ -34,8 +35,12 @@ export async function createService( // are compared using _.isEqual so leaving this here to have image comparisons // match serviceId: 1, - imageId: 1, - releaseId: 1, + ...(isTarget + ? { + imageId: 1, + releaseId: 1, + } + : {}), ...conf, }, options,