mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 18:19:51 +00:00
2fc46bdcfa
* test(manager): replace file snapshots with explicit assertions * test(manager): replace inline snapshots with explicit assertions * test(manager): assert on relevant sections instead of full bodies * test(manager): drop assertions implied by full equality * test(manager): address review feedback * test(manager): assert depType and versioning in the regex matcher
188 lines
5.9 KiB
TypeScript
188 lines
5.9 KiB
TypeScript
import { isPlainObject } from '@sindresorhus/is';
|
|
import { Fixtures } from '~test/fixtures.ts';
|
|
import { parseDepsEdnFile } from './parser.ts';
|
|
|
|
describe('modules/manager/deps-edn/parser', () => {
|
|
describe('parseEdnFile', () => {
|
|
it.each`
|
|
input | output
|
|
${''} | ${undefined}
|
|
${':foo'} | ${undefined}
|
|
${'foo'} | ${undefined}
|
|
${'1'} | ${undefined}
|
|
${'1.5'} | ${undefined}
|
|
${'1e1'} | ${undefined}
|
|
${'1e-1'} | ${undefined}
|
|
${'[]'} | ${undefined}
|
|
${'}'} | ${undefined}
|
|
${'{}'} | ${{}}
|
|
${'{'} | ${{}}
|
|
${'{:foo :foo}'} | ${{ foo: 'foo' }}
|
|
${'{:foo foo}'} | ${{ foo: 'foo' }}
|
|
${'{:foo 1}'} | ${{ foo: '1' }}
|
|
${'{:foo 1.5}'} | ${{ foo: '1.5' }}
|
|
${'{:foo 1e1}'} | ${{ foo: '1e1' }}
|
|
${'{:foo 1e-1}'} | ${{ foo: '1e-1' }}
|
|
${'{:foo {}}'} | ${{ foo: {} }}
|
|
${'{{} :foo}'} | ${{}}
|
|
${'{{} {}}'} | ${{}}
|
|
${'{:foo :bar}'} | ${{ foo: 'bar' }}
|
|
${'{:foo 1 :bar 2}'} | ${{ foo: '1', bar: '2' }}
|
|
${'{:foo {:bar 2} :baz}'} | ${{ foo: { bar: '2' } }}
|
|
${'{:foo [:bar :baz]}'} | ${{ foo: ['bar', 'baz'] }}
|
|
${'{:foo {:bar :baz}}'} | ${{ foo: { bar: 'baz' } }}
|
|
${'{:foo [{:bar :baz}]}'} | ${{ foo: [{ bar: 'baz' }] }}
|
|
${'{:foo {:bar :baz}}'} | ${{ foo: { bar: 'baz' } }}
|
|
`(`'$input' parses to $output`, ({ input, output }) => {
|
|
const res = parseDepsEdnFile(input);
|
|
expect(res?.data).toEqual(output);
|
|
});
|
|
|
|
it('extracts file', () => {
|
|
const content = Fixtures.get('deps.edn');
|
|
const res = parseDepsEdnFile(content);
|
|
|
|
expect(res?.data).toEqual({
|
|
aliases: {
|
|
'1.10': {
|
|
'override-deps': {
|
|
'org.clojure/clojure': {
|
|
'mvn/version': '1.10.0',
|
|
},
|
|
},
|
|
},
|
|
'1.9': {
|
|
'override-deps': {
|
|
'org.clojure/clojure': {
|
|
'mvn/version': '1.9.0',
|
|
},
|
|
},
|
|
},
|
|
datomic: {
|
|
'extra-deps': {
|
|
'com.datomic/datomic-free': {
|
|
'mvn/version': '0.9.5703',
|
|
},
|
|
},
|
|
},
|
|
dev: {
|
|
'extra-deps': {
|
|
'org.clojure/clojurescript': {
|
|
'mvn/version': '1.10.520',
|
|
},
|
|
'org.clojure/tools.namespace': {
|
|
'mvn/version': '0.2.11',
|
|
},
|
|
},
|
|
'extra-paths': ['dev', 'target/classes'],
|
|
},
|
|
repl: {
|
|
'extra-deps': {
|
|
'cider/cider-nrepl': {
|
|
'mvn/version': '0.21.1',
|
|
},
|
|
'nrepl/nrepl': {
|
|
'mvn/version': '0.6.0',
|
|
},
|
|
'org.clojure/tools.namespace': {
|
|
'mvn/version': '0.2.11',
|
|
},
|
|
},
|
|
'main-opts': [
|
|
'-m',
|
|
'nrepl.cmdline',
|
|
'--middleware',
|
|
'[cider.nrepl/cider-middleware]',
|
|
],
|
|
},
|
|
test: {
|
|
'extra-deps': {
|
|
'io.github.lambdaisland/kaocha-cljs': {
|
|
'git/tag': '0.0-21',
|
|
},
|
|
'lambdaisland/kaocha': {
|
|
'git/tag': '0.0-389',
|
|
'git/url': 'https://github.com/lambdaisland/kaocha.git',
|
|
},
|
|
'org.clojure/clojurescript': {
|
|
'mvn/version': '1.10.520',
|
|
},
|
|
},
|
|
'extra-paths': ['test'],
|
|
},
|
|
'test-bitbucket': {
|
|
'extra-deps': {
|
|
'lambdaisland/kaocha': {
|
|
'git/tag': '0.0-389',
|
|
'git/url': 'https://bitbucket.org/lambdaisland/kaocha.git',
|
|
},
|
|
'org.bitbucket.lambdaisland/kaocha-cljs': {
|
|
'git/tag': '0.0-21',
|
|
},
|
|
},
|
|
'extra-paths': ['test'],
|
|
},
|
|
'test-git': {
|
|
'extra-deps': {
|
|
'bar/bar': {
|
|
'git/url': 'https://example.com/bar.git',
|
|
},
|
|
'baz/baz': {},
|
|
'foo/foo': {
|
|
'git/sha': '123',
|
|
'git/url': 'git@example.com/foo.git',
|
|
},
|
|
},
|
|
'extra-paths': ['test'],
|
|
},
|
|
'test-gitlab': {
|
|
'extra-deps': {
|
|
'com.gitlab.lambdaisland/kaocha-cljs': {
|
|
'git/tag': '0.0-21',
|
|
},
|
|
'lambdaisland/kaocha': {
|
|
'git/tag': '0.0-389',
|
|
'git/url': 'https://gitlab.com/lambdaisland/kaocha.git',
|
|
},
|
|
},
|
|
'extra-paths': ['test'],
|
|
},
|
|
},
|
|
deps: {
|
|
'invalid/package!': {
|
|
'mvn/version': '1.2.3',
|
|
},
|
|
'invalid/version': 'nil',
|
|
'io.github.nextjournal/clerk': {
|
|
'mvn/version': '0.7.418',
|
|
},
|
|
'persistent-sorted-set': {
|
|
'mvn/version': '0.1.2',
|
|
},
|
|
},
|
|
'mvn/repos': {
|
|
central: 'nil',
|
|
clojars: {
|
|
url: 'https://deps.com/foo/bar',
|
|
},
|
|
'my-auth-repo': {
|
|
url: 'https://my.auth.com/repo',
|
|
},
|
|
'my-private-repo': {
|
|
url: 's3://my-bucket/maven/releases',
|
|
},
|
|
},
|
|
});
|
|
|
|
const dep =
|
|
isPlainObject(res) &&
|
|
isPlainObject(res.data.deps) &&
|
|
isPlainObject(res.data.deps['persistent-sorted-set']) &&
|
|
res.data.deps['persistent-sorted-set'];
|
|
expect(dep && res?.metadata?.get(dep)).toEqual({
|
|
replaceString: '{:mvn/version,"0.1.2"}',
|
|
});
|
|
});
|
|
});
|
|
});
|