Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
63423a17
Unverified
Commit
63423a17
authored
3 years ago
by
Sergei Zharinov
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test(pep440): Refactor versioning scheme (#11930)
Co-authored-by:
Michael Kriese
<
michael.kriese@visualon.de
>
parent
959e3943
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/versioning/pep440/index.spec.ts
+168
-191
168 additions, 191 deletions
lib/versioning/pep440/index.spec.ts
with
168 additions
and
191 deletions
lib/versioning/pep440/index.spec.ts
+
168
−
191
View file @
63423a17
import
pep440
from
'
.
'
;
describe
(
'
versioning/pep440/index
'
,
()
=>
{
describe
(
'
pep440.isValid(input)
'
,
()
=>
{
it
(
'
should support a version without equals
'
,
()
=>
{
expect
(
pep440
.
isValid
(
'
0.750
'
)).
toBeTruthy
();
expect
(
pep440
.
isValid
(
'
1.2.3
'
)).
toBeTruthy
();
expect
(
pep440
.
isValid
(
'
1.9
'
)).
toBeTruthy
();
});
it
(
'
should support irregular versions
'
,
()
=>
{
expect
(
pep440
.
isValid
(
'
17.04.0
'
)).
toBeTruthy
();
});
it
(
'
should support simple pep440
'
,
()
=>
{
expect
(
pep440
.
isValid
(
'
==1.2.3
'
)).
toBeTruthy
();
});
it
(
'
should support pep440 with RC
'
,
()
=>
{
expect
(
pep440
.
isValid
(
'
==1.2.3rc0
'
)).
toBeTruthy
();
});
it
(
'
should support ranges
'
,
()
=>
{
expect
(
pep440
.
isValid
(
'
~=1.2.3
'
)).
toBeTruthy
();
expect
(
pep440
.
isValid
(
'
==1.2.*
'
)).
toBeTruthy
();
expect
(
pep440
.
isValid
(
'
>1.2.3
'
)).
toBeTruthy
();
});
it
(
'
should reject github repositories
'
,
()
=>
{
expect
(
pep440
.
isValid
(
'
renovatebot/renovate
'
)).
toBeFalsy
();
expect
(
pep440
.
isValid
(
'
renovatebot/renovate#master
'
)).
toBeFalsy
();
expect
(
pep440
.
isValid
(
'
https://github.com/renovatebot/renovate.git
'
)
).
toBeFalsy
();
});
});
describe
(
'
pep440.isStable(version)
'
,
()
=>
{
it
(
'
returns correct value
'
,
()
=>
{
expect
(
pep440
.
isStable
(
'
1.2.3
'
)).
toBeTruthy
();
expect
(
pep440
.
isStable
(
'
1.2.3rc0
'
)).
toBeFalsy
();
});
it
(
'
returns false when version invalid
'
,
()
=>
{
expect
(
pep440
.
isStable
(
'
not_version
'
)).
toBeFalsy
();
});
});
describe
(
'
pep440.equals(version1, version2)
'
,
()
=>
{
it
(
'
returns correct true
'
,
()
=>
{
expect
(
pep440
.
equals
(
'
1.0
'
,
'
1.0.0
'
)).
toBeTruthy
();
});
it
(
'
returns false when version invalid
'
,
()
=>
{
expect
(
pep440
.
equals
(
'
1.0.0
'
,
'
1.0..foo
'
)).
toBeFalsy
();
});
});
describe
(
'
pep440.isSingleVersion()
'
,
()
=>
{
it
(
'
returns true if naked version
'
,
()
=>
{
expect
(
pep440
.
isSingleVersion
(
'
1.2.3
'
)).
toBeTruthy
();
expect
(
pep440
.
isSingleVersion
(
'
1.2.3rc0
'
)).
toBeTruthy
();
});
it
(
'
returns true if double equals
'
,
()
=>
{
expect
(
pep440
.
isSingleVersion
(
'
==1.2.3
'
)).
toBeTruthy
();
expect
(
pep440
.
isSingleVersion
(
'
==1.2
'
)).
toBeTruthy
();
expect
(
pep440
.
isSingleVersion
(
'
== 1.2.3
'
)).
toBeTruthy
();
});
it
(
'
returns false when not version
'
,
()
=>
{
expect
(
pep440
.
isSingleVersion
(
'
==1.*
'
)).
toBeFalsy
();
});
test
.
each
`
input | expected
${
'
0.750
'
}
|
${
true
}
${
'
1.2.3
'
}
|
${
true
}
${
'
1.9
'
}
|
${
true
}
${
'
17.04.0
'
}
|
${
true
}
${
'
==1.2.3
'
}
|
${
true
}
${
'
==1.2.3rc0
'
}
|
${
true
}
${
'
~=1.2.3
'
}
|
${
true
}
${
'
==1.2.*
'
}
|
${
true
}
${
'
>1.2.3
'
}
|
${
true
}
${
'
renovatebot/renovate
'
}
|
${
false
}
${
'
renovatebot/renovate#master
'
}
|
${
false
}
${
'
https://github.com/renovatebot/renovate.git
'
}
|
${
false
}
`
(
'
isValid("$input") === $expected
'
,
({
input
,
expected
})
=>
{
const
res
=
!!
pep440
.
isValid
(
input
);
expect
(
res
).
toBe
(
expected
);
});
test
.
each
`
input | expected
${
'
1.2.3
'
}
|
${
true
}
${
'
1.2.3rc0
'
}
|
${
false
}
${
'
not_version
'
}
|
${
false
}
`
(
'
isStable("$input") === $expected
'
,
({
input
,
expected
})
=>
{
expect
(
pep440
.
isStable
(
input
)).
toBe
(
expected
);
});
test
.
each
`
a | b | expected
${
'
1.0
'
}
|
${
'
1.0.0
'
}
|
${
true
}
${
'
1.0.0
'
}
|
${
'
1.0..foo
'
}
|
${
null
}
`
(
'
equals($a, $b) === $expected
'
,
({
a
,
b
,
expected
})
=>
{
expect
(
pep440
.
equals
(
a
,
b
)).
toBe
(
expected
);
});
test
.
each
`
version | isSingle
${
'
1.2.3
'
}
|
${
true
}
${
'
1.2.3rc0
'
}
|
${
true
}
${
'
==1.2.3
'
}
|
${
true
}
${
'
==1.2
'
}
|
${
true
}
${
'
== 1.2.3
'
}
|
${
true
}
${
'
==1.*
'
}
|
${
false
}
`
(
'
isSingleVersion("$version") === $isSingle
'
,
({
version
,
isSingle
})
=>
{
const
res
=
!!
pep440
.
isSingleVersion
(
version
);
expect
(
res
).
toBe
(
isSingle
);
});
const
versions
=
[
...
...
@@ -75,143 +61,134 @@ describe('versioning/pep440/index', () => {
'
2.0.3
'
,
];
describe
(
'
pep440.getSatisfyingVersion(versions, range)
'
,
()
=>
{
it
(
'
returns correct value
'
,
()
=>
{
expect
(
pep440
.
getSatisfyingVersion
(
versions
,
'
~=1.2.1
'
)).
toBe
(
'
1.2.3
'
);
});
it
(
'
returns null when none found
'
,
()
=>
{
expect
(
pep440
.
getSatisfyingVersion
(
versions
,
'
~=2.1
'
)).
toBeNull
();
});
});
describe
(
'
pep440.minSatisfyingVersion(versions, range)
'
,
()
=>
{
it
(
'
returns correct value
'
,
()
=>
{
expect
(
pep440
.
minSatisfyingVersion
(
versions
,
'
~=1.2.1
'
)).
toBe
(
'
1.2.1
'
);
});
it
(
'
returns null when none found
'
,
()
=>
{
expect
(
pep440
.
minSatisfyingVersion
(
versions
,
'
~=2.1
'
)).
toBeNull
();
});
});
describe
(
'
pep440.getNewValue()
'
,
()
=>
{
const
{
getNewValue
}
=
pep440
;
// cases: [currentValue, expectedBump]
[
// plain version
[
'
1.0.0
'
,
'
1.2.3
'
],
// simple cases
[
'
==1.0.3
'
,
'
==1.2.3
'
],
[
'
>=1.2.0
'
,
'
>=1.2.3
'
],
[
'
~=1.2.0
'
,
'
~=1.2.3
'
],
[
'
~=1.0.3
'
,
'
~=1.2.3
'
],
// glob
[
'
==1.2.*
'
,
'
==1.2.*
'
],
[
'
==1.0.*
'
,
'
==1.2.*
'
],
// future versions guard
[
'
<1.2.2.3
'
,
'
<1.2.4.0
'
],
[
'
<1.2.3
'
,
'
<1.2.4
'
],
[
'
<1.2
'
,
'
<1.3
'
],
[
'
<1
'
,
'
<2
'
],
[
'
<2.0.0
'
,
'
<2.0.0
'
],
// minimum version guard
[
'
>0.9.8
'
,
'
>0.9.8
'
],
// rollback
[
'
>2.0.0
'
,
'
>=1.2.3
'
],
[
'
>=2.0.0
'
,
'
>=1.2.3
'
],
// complex ranges
[
'
~=1.1.0, !=1.1.1
'
,
'
~=1.2.3, !=1.1.1
'
],
[
'
~=1.1.0,!=1.1.1
'
,
'
~=1.2.3,!=1.1.1
'
],
// invalid & not supported
[
'
'
,
'
'
],
[
'
invalid
'
,
null
],
[
'
===1.0.3
'
,
null
],
// impossible
[
'
!=1.2.3
'
,
null
],
].
forEach
(([
currentValue
,
expectedBump
])
=>
{
const
bumped
=
getNewValue
({
test
.
each
`
range | expected
${
'
~=1.2.1
'
}
|
${
'
1.2.3
'
}
${
'
~=2.1
'
}
|
${
null
}
`
(
'
getSatisfyingVersion($versions, "$range") === $expected
'
,
({
range
,
expected
})
=>
{
expect
(
pep440
.
getSatisfyingVersion
(
versions
,
range
)).
toBe
(
expected
);
}
);
test
.
each
`
range | expected
${
'
~=1.2.1
'
}
|
${
'
1.2.1
'
}
${
'
~=2.1
'
}
|
${
null
}
`
(
'
minSatisfyingVersion($versions, "$range") === $expected
'
,
({
range
,
expected
})
=>
{
expect
(
pep440
.
minSatisfyingVersion
(
versions
,
range
)).
toBe
(
expected
);
}
);
test
.
each
`
currentValue | rangeStrategy | currentVersion | newVersion | expected
${
'
1.0.0
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
1.2.3
'
}
${
'
1.0.0
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
1.2.3
'
}
${
'
1.0.0
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
==1.0.3
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
==1.0.3
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
==1.0.3
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
>=1.2.0
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
>=1.2.3
'
}
${
'
>=1.2.0
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
>=1.2.0
'
}
${
'
>=1.2.0
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
~=1.2.0
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
~=1.2.3
'
}
${
'
~=1.2.0
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
~=1.2.0
'
}
${
'
~=1.2.0
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
~=1.0.3
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
~=1.2.3
'
}
${
'
~=1.0.3
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
~=1.2.3
'
}
${
'
~=1.0.3
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
==1.2.*
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.*
'
}
${
'
==1.2.*
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.*
'
}
${
'
==1.2.*
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
==1.0.*
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.*
'
}
${
'
==1.0.*
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.*
'
}
${
'
==1.0.*
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
<1.2.2.3
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<1.2.4.0
'
}
${
'
<1.2.2.3
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<1.2.4.0
'
}
${
'
<1.2.2.3
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
<1.2.3
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<1.2.4
'
}
${
'
<1.2.3
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<1.2.4
'
}
${
'
<1.2.3
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
<1.2
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<1.3
'
}
${
'
<1.2
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<1.3
'
}
${
'
<1.2
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
<1
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<2
'
}
${
'
<1
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<2
'
}
${
'
<1
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
<2.0.0
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<2.0.0
'
}
${
'
<2.0.0
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
<2.0.0
'
}
${
'
<2.0.0
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
>0.9.8
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
>0.9.8
'
}
${
'
>0.9.8
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
>0.9.8
'
}
${
'
>0.9.8
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
>2.0.0
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
>=1.2.3
'
}
${
'
>2.0.0
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
>=1.2.3
'
}
${
'
>2.0.0
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
>=2.0.0
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
>=1.2.3
'
}
${
'
>=2.0.0
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
>=1.2.3
'
}
${
'
>=2.0.0
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
~=1.1.0, !=1.1.1
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
~=1.2.3, !=1.1.1
'
}
${
'
~=1.1.0, !=1.1.1
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
~=1.2.3, !=1.1.1
'
}
${
'
~=1.1.0, !=1.1.1
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
~=1.1.0,!=1.1.1
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
~=1.2.3,!=1.1.1
'
}
${
'
~=1.1.0,!=1.1.1
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
~=1.2.3,!=1.1.1
'
}
${
'
~=1.1.0,!=1.1.1
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
'
}
${
'
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
'
}
${
'
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
invalid
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
null
}
${
'
invalid
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
null
}
${
'
invalid
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
===1.0.3
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
null
}
${
'
===1.0.3
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
null
}
${
'
===1.0.3
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
${
'
!=1.2.3
'
}
|
${
'
bump
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
null
}
${
'
!=1.2.3
'
}
|
${
'
replace
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
null
}
${
'
!=1.2.3
'
}
|
${
'
pin
'
}
|
${
'
1.0.0
'
}
|
${
'
1.2.3
'
}
|
${
'
==1.2.3
'
}
`
(
'
getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"
'
,
({
currentValue
,
rangeStrategy
,
currentVersion
,
newVersion
,
expected
})
=>
{
const
res
=
pep440
.
getNewValue
({
currentValue
,
rangeStrategy
:
'
bump
'
,
currentVersion
:
'
1.0.0
'
,
newVersion
:
'
1.2.3
'
,
});
it
(
`bumps '
${
currentValue
}
' to '
${
expectedBump
}
'`
,
()
=>
{
expect
(
bumped
).
toBe
(
expectedBump
);
});
const
replaced
=
getNewValue
({
currentValue
,
rangeStrategy
:
'
replace
'
,
currentVersion
:
'
1.0.0
'
,
newVersion
:
'
1.2.3
'
,
});
const
needReplace
=
pep440
.
matches
(
'
1.2.3
'
,
currentValue
);
const
expectedReplace
=
needReplace
?
currentValue
:
bumped
;
it
(
`replaces '
${
currentValue
}
' to '
${
expectedReplace
}
'`
,
()
=>
{
expect
(
replaced
).
toBe
(
expectedReplace
);
});
const
pinned
=
getNewValue
({
currentValue
,
rangeStrategy
:
'
pin
'
,
currentVersion
:
'
1.0.0
'
,
newVersion
:
'
1.2.3
'
,
});
const
expectedPin
=
'
==1.2.3
'
;
it
(
`pins '
${
currentValue
}
' to '
${
expectedPin
}
'`
,
()
=>
{
expect
(
pinned
).
toBe
(
expectedPin
);
});
});
it
(
'
guards against unsupported rangeStrategy
'
,
()
=>
{
const
invalid
=
getNewValue
({
currentValue
:
'
==1.0.0
'
,
rangeStrategy
:
'
update-lockfile
'
,
currentVersion
:
'
1.0.0
'
,
newVersion
:
'
1.2.3
'
,
});
expect
(
invalid
).
toEqual
(
'
==1.2.3
'
);
});
});
describe
(
'
pep.isLessThanRange()
'
,
()
=>
{
test
.
each
([
[
'
>= 1.0.0, < 2.0.0
'
,
'
0.9.9.9
'
,
true
],
[
'
>= 1.0.0, < 2.0.0
'
,
'
1.0.0a0
'
,
true
],
[
'
> 1.0.0, < 2.0.0
'
,
'
1.0.0.0
'
,
true
],
[
'
> 1.0.0, < 2.0.0
'
,
'
2.0.1.0
'
,
false
],
[
'
> 1.0.0, < 2.0.0
'
,
'
2.0.0.0
'
,
false
],
[
'
> 1.0.0, < 2.0.0
'
,
'
2.0.0a0
'
,
false
],
[
'
== 1.2.3
'
,
'
1.2.2.9
'
,
true
],
[
'
== 1.2.3
'
,
'
1.2.3a0
'
,
true
],
[
'
== 1.2.3
'
,
'
1.2.3.0
'
,
false
],
[
'
== 1.2.3
'
,
'
1.2.3.1
'
,
false
],
[
'
== 1.2.3
'
,
'
1.2.4a0
'
,
false
],
[
'
!= 1.2.3
'
,
'
1.2.2.9
'
,
false
],
[
'
!= 1.2.3
'
,
'
1.2.3.0
'
,
false
],
[
'
!= 1.2.3
'
,
'
1.2.3.1
'
,
false
],
[
'
< 1.0.0
'
,
'
0.0.1
'
,
false
],
[
'
< 1.0.0
'
,
'
1.0.0
'
,
false
],
[
'
< 1.0.0
'
,
'
2.0.0
'
,
false
],
[
'
<= 1.0.0
'
,
'
0.0.1
'
,
false
],
[
'
<= 1.0.0
'
,
'
1.0.0
'
,
false
],
[
'
<= 1.0.0
'
,
'
2.0.0
'
,
false
],
[
'
< 1.0.0, > 2.0.0
'
,
'
0.0.1
'
,
true
],
// fixme (maybe)
[
'
< 1.0.0, > 2.0.0
'
,
'
3.0.0
'
,
false
],
])(
`%s\t%s\t%s`
,
(
range
,
version
,
expected
)
=>
{
rangeStrategy
,
currentVersion
,
newVersion
,
});
expect
(
res
).
toEqual
(
expected
);
}
);
test
.
each
`
version | range | expected
${
'
0.9.9.9
'
}
|
${
'
>= 1.0.0, < 2.0.0
'
}
|
${
true
}
${
'
1.0.0a0
'
}
|
${
'
>= 1.0.0, < 2.0.0
'
}
|
${
true
}
${
'
1.0.0.0
'
}
|
${
'
> 1.0.0, < 2.0.0
'
}
|
${
true
}
${
'
2.0.1.0
'
}
|
${
'
> 1.0.0, < 2.0.0
'
}
|
${
false
}
${
'
2.0.0.0
'
}
|
${
'
> 1.0.0, < 2.0.0
'
}
|
${
false
}
${
'
2.0.0a0
'
}
|
${
'
> 1.0.0, < 2.0.0
'
}
|
${
false
}
${
'
1.2.2.9
'
}
|
${
'
== 1.2.3
'
}
|
${
true
}
${
'
1.2.3a0
'
}
|
${
'
== 1.2.3
'
}
|
${
true
}
${
'
1.2.3.0
'
}
|
${
'
== 1.2.3
'
}
|
${
false
}
${
'
1.2.3.1
'
}
|
${
'
== 1.2.3
'
}
|
${
false
}
${
'
1.2.4a0
'
}
|
${
'
== 1.2.3
'
}
|
${
false
}
${
'
1.2.2.9
'
}
|
${
'
!= 1.2.3
'
}
|
${
false
}
${
'
1.2.3.0
'
}
|
${
'
!= 1.2.3
'
}
|
${
false
}
${
'
1.2.3.1
'
}
|
${
'
!= 1.2.3
'
}
|
${
false
}
${
'
0.0.1
'
}
|
${
'
< 1.0.0
'
}
|
${
false
}
${
'
1.0.0
'
}
|
${
'
< 1.0.0
'
}
|
${
false
}
${
'
2.0.0
'
}
|
${
'
< 1.0.0
'
}
|
${
false
}
${
'
0.0.1
'
}
|
${
'
<= 1.0.0
'
}
|
${
false
}
${
'
1.0.0
'
}
|
${
'
<= 1.0.0
'
}
|
${
false
}
${
'
2.0.0
'
}
|
${
'
<= 1.0.0
'
}
|
${
false
}
${
'
0.0.1
'
}
|
${
'
< 1.0.0, > 2.0.0
'
}
|
${
true
}
${
'
3.0.0
'
}
|
${
'
< 1.0.0, > 2.0.0
'
}
|
${
false
}
`
(
'
isLessThanRange("$version", "$range") === "$expected"
'
,
({
version
,
range
,
expected
})
=>
{
expect
(
pep440
.
isLessThanRange
(
version
,
range
)).
toBe
(
expected
);
}
);
}
);
}
);
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment