-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager:bundler): move constraint extraction to update artifacts (…
…#15125) * feat(manager:bundler): move constraint extraction to update artifacts * fix: missing null checks * chore: add comment * chore: not null save transitives * chore: fix snapshot
- Loading branch information
Showing
10 changed files
with
216 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { join } from 'upath'; | ||
import { Fixtures } from '../../../../test/fixtures'; | ||
import { fs, partial } from '../../../../test/util'; | ||
import { GlobalConfig } from '../../../config/global'; | ||
import type { RepoGlobalConfig } from '../../../config/types'; | ||
import type { UpdateArtifact } from '../types'; | ||
import { getBundlerConstraint, getRubyConstraint } from './common'; | ||
|
||
jest.mock('../../../util/fs'); | ||
|
||
const gemfile = Fixtures.get('Gemfile.sourceGroup'); | ||
const lockedContent = Fixtures.get('Gemfile.gitlab-foss.lock'); | ||
|
||
const adminConfig: RepoGlobalConfig = { | ||
// `join` fixes Windows CI | ||
localDir: join('/tmp/github/some/repo'), | ||
cacheDir: join('/tmp/cache'), | ||
}; | ||
|
||
describe('modules/manager/bundler/common', () => { | ||
beforeEach(() => { | ||
GlobalConfig.set(adminConfig); | ||
}); | ||
|
||
describe('getBundlerConstraint', () => { | ||
it('uses existing contraint', () => { | ||
const config: Pick<UpdateArtifact, 'config'> = { | ||
config: { | ||
constraints: { bundler: '2.1.0' }, | ||
}, | ||
}; | ||
const version = getBundlerConstraint(config, lockedContent); | ||
expect(version).toBe('2.1.0'); | ||
}); | ||
|
||
it('extracts from lockfile', () => { | ||
const config: Pick<UpdateArtifact, 'config'> = { | ||
config: {}, | ||
}; | ||
const version = getBundlerConstraint(config, lockedContent); | ||
expect(version).toBe('1.17.3'); | ||
}); | ||
|
||
it('returns null', () => { | ||
const config: Pick<UpdateArtifact, 'config'> = { | ||
config: {}, | ||
}; | ||
const version = getBundlerConstraint(config, ''); | ||
expect(version).toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('getRubyConstraint', () => { | ||
it('uses existing contraint', async () => { | ||
const config = partial<UpdateArtifact>({ | ||
packageFileName: 'Gemfile', | ||
newPackageFileContent: gemfile, | ||
config: { | ||
constraints: { ruby: '2.1.0' }, | ||
}, | ||
}); | ||
const version = await getRubyConstraint(config); | ||
expect(version).toBe('2.1.0'); | ||
}); | ||
|
||
it('extracts from lockfile', async () => { | ||
const config = partial<UpdateArtifact>({ | ||
packageFileName: 'Gemfile', | ||
newPackageFileContent: gemfile, | ||
config: {}, | ||
}); | ||
const version = await getRubyConstraint(config); | ||
expect(version).toBe('~> 1.5.3'); | ||
}); | ||
|
||
it('extracts from .ruby-version', async () => { | ||
const config = partial<UpdateArtifact>({ | ||
packageFileName: 'Gemfile', | ||
newPackageFileContent: '', | ||
config: {}, | ||
}); | ||
fs.readLocalFile.mockResolvedValueOnce('ruby-1.2.3'); | ||
const version = await getRubyConstraint(config); | ||
expect(version).toBe('1.2.3'); | ||
}); | ||
|
||
it('returns null', async () => { | ||
const config = partial<UpdateArtifact>({ | ||
packageFileName: 'Gemfile', | ||
newPackageFileContent: '', | ||
config: {}, | ||
}); | ||
const version = await getRubyConstraint(config); | ||
expect(version).toBeNull(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.