From 956003a21179d2c69a4ca65b7d4715969673362b Mon Sep 17 00:00:00 2001 From: Leandro Date: Tue, 31 Dec 2024 13:39:04 +0100 Subject: [PATCH] Fix unit tests --- lib/modules/manager/bundler/artifacts.spec.ts | 216 +----------------- 1 file changed, 2 insertions(+), 214 deletions(-) diff --git a/lib/modules/manager/bundler/artifacts.spec.ts b/lib/modules/manager/bundler/artifacts.spec.ts index 497d293a06b552..ad0ee829c84efb 100644 --- a/lib/modules/manager/bundler/artifacts.spec.ts +++ b/lib/modules/manager/bundler/artifacts.spec.ts @@ -435,217 +435,6 @@ describe('modules/manager/bundler/artifacts', () => { datasource.getPkgReleases.mockResolvedValueOnce({ releases: [{ version: '1.17.2' }, { version: '2.3.5' }], }); - bundlerHostRules.findAllAuthenticatable.mockReturnValue([ - { - hostType: 'bundler', - matchHost: 'gems.private.com', - resolvedHost: 'gems.private.com', - username: 'some-user', - password: 'some-password', - }, - ]); - bundlerHostRules.getAuthenticationHeaderValue.mockReturnValue( - 'some-user:some-password', - ); - const execSnapshots = mockExecAll(); - git.getRepoStatus.mockResolvedValueOnce( - partial({ - modified: ['Gemfile.lock'], - }), - ); - fs.readLocalFile.mockResolvedValueOnce('Updated Gemfile.lock'); - expect( - await updateArtifacts({ - packageFileName: 'Gemfile', - updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }], - newPackageFileContent: 'Updated Gemfile content', - config, - }), - ).toEqual([updatedGemfileLock]); - expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, - { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, - { - cmd: - 'docker run --rm --name=renovate_sidecar --label=renovate_child ' + - '-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' + - '-v "/tmp/cache":"/tmp/cache" ' + - '-e BUNDLE_GEMS__PRIVATE__COM ' + - '-e GEM_HOME ' + - '-e CONTAINERBASE_CACHE_DIR ' + - '-w "/tmp/github/some/repo" ' + - 'ghcr.io/containerbase/sidecar' + - ' bash -l -c "' + - 'install-tool ruby 1.2.0' + - ' && ' + - 'install-tool bundler 2.3.5' + - ' && ' + - 'ruby --version' + - ' && ' + - 'bundler lock --update foo bar' + - '"', - }, - ]); - }); - - it('injects bundler host configuration as command with bundler < 2', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); - fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); - fs.readLocalFile.mockResolvedValueOnce('1.2.0'); - // ruby - datasource.getPkgReleases.mockResolvedValueOnce({ - releases: [ - { version: '1.0.0' }, - { version: '1.2.0' }, - { version: '1.3.0' }, - ], - }); - bundlerHostRules.findAllAuthenticatable.mockReturnValue([ - { - hostType: 'bundler', - matchHost: 'gems-private.com', - resolvedHost: 'gems-private.com', - username: 'some-user', - password: 'some-password', - }, - ]); - bundlerHostRules.getAuthenticationHeaderValue.mockReturnValue( - 'some-user:some-password', - ); - const execSnapshots = mockExecAll(); - git.getRepoStatus.mockResolvedValueOnce( - partial({ - modified: ['Gemfile.lock'], - }), - ); - fs.readLocalFile.mockResolvedValueOnce('Updated Gemfile.lock'); - expect( - await updateArtifacts({ - packageFileName: 'Gemfile', - updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }], - newPackageFileContent: 'Updated Gemfile content', - config: { - ...config, - constraints: { - bundler: '1.2', - }, - }, - }), - ).toEqual([updatedGemfileLock]); - expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, - { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, - { - cmd: - 'docker run --rm --name=renovate_sidecar --label=renovate_child ' + - '-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' + - '-v "/tmp/cache":"/tmp/cache" ' + - '-e GEM_HOME ' + - '-e CONTAINERBASE_CACHE_DIR ' + - '-w "/tmp/github/some/repo" ' + - 'ghcr.io/containerbase/sidecar' + - ' bash -l -c "' + - 'install-tool ruby 1.2.0' + - ' && ' + - 'install-tool bundler 1.2' + - ' && ' + - 'ruby --version' + - ' && ' + - 'bundler config --local gems-private.com some-user:some-password' + - ' && ' + - 'bundler lock --update foo bar' + - '"', - }, - ]); - }); - - it('injects bundler host configuration as command with bundler >= 2', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); - fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); - fs.readLocalFile.mockResolvedValueOnce('1.2.0'); - // ruby - datasource.getPkgReleases.mockResolvedValueOnce({ - releases: [ - { version: '1.0.0' }, - { version: '1.2.0' }, - { version: '1.3.0' }, - ], - }); - bundlerHostRules.findAllAuthenticatable.mockReturnValue([ - { - hostType: 'bundler', - matchHost: 'gems-private.com', - resolvedHost: 'gems-private.com', - username: 'some-user', - password: 'some-password', - }, - ]); - bundlerHostRules.getAuthenticationHeaderValue.mockReturnValue( - 'some-user:some-password', - ); - const execSnapshots = mockExecAll(); - git.getRepoStatus.mockResolvedValueOnce( - partial({ - modified: ['Gemfile.lock'], - }), - ); - fs.readLocalFile.mockResolvedValueOnce('Updated Gemfile.lock'); - expect( - await updateArtifacts({ - packageFileName: 'Gemfile', - updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }], - newPackageFileContent: 'Updated Gemfile content', - config: { - ...config, - constraints: { - bundler: '2.1', - }, - }, - }), - ).toEqual([updatedGemfileLock]); - expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, - { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, - { - cmd: - 'docker run --rm --name=renovate_sidecar --label=renovate_child ' + - '-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' + - '-v "/tmp/cache":"/tmp/cache" ' + - '-e GEM_HOME ' + - '-e CONTAINERBASE_CACHE_DIR ' + - '-w "/tmp/github/some/repo" ' + - 'ghcr.io/containerbase/sidecar' + - ' bash -l -c "' + - 'install-tool ruby 1.2.0' + - ' && ' + - 'install-tool bundler 2.1' + - ' && ' + - 'ruby --version' + - ' && ' + - 'bundler config set --local gems-private.com some-user:some-password' + - ' && ' + - 'bundler lock --update foo bar' + - '"', - }, - ]); - }); - - it('injects bundler host configuration as command with bundler == latest', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); - fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); - fs.readLocalFile.mockResolvedValueOnce('1.2.0'); - // ruby - datasource.getPkgReleases.mockResolvedValueOnce({ - releases: [ - { version: '1.0.0' }, - { version: '1.2.0' }, - { version: '1.3.0' }, - ], - }); - // bundler - datasource.getPkgReleases.mockResolvedValueOnce({ - releases: [{ version: '1.17.2' }, { version: '2.3.5' }], - }); bundlerHostRules.findAllAuthenticatable.mockReturnValue([ { hostType: 'bundler', @@ -681,6 +470,7 @@ describe('modules/manager/bundler/artifacts', () => { 'docker run --rm --name=renovate_sidecar --label=renovate_child ' + '-v "/tmp/github/some/repo":"/tmp/github/some/repo" ' + '-v "/tmp/cache":"/tmp/cache" ' + + '-e BUNDLE_GEMS___PRIVATE__COM ' + '-e GEM_HOME ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + @@ -688,12 +478,10 @@ describe('modules/manager/bundler/artifacts', () => { ' bash -l -c "' + 'install-tool ruby 1.2.0' + ' && ' + - 'install-tool bundler 1.3.0' + + 'install-tool bundler 2.3.5' + ' && ' + 'ruby --version' + ' && ' + - 'bundler config set --local gems-private.com some-user:some-password' + - ' && ' + 'bundler lock --update foo bar' + '"', },