-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
various fixes and tests for [githubpipenv] #7194
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import { expect } from 'chai' | ||
import { getDependencyVersion } from './pipenv-helpers.js' | ||
import { InvalidParameter } from './index.js' | ||
|
||
describe('getDependencyVersion', function () { | ||
// loosely based on https://github.com/pypa/pipfile#pipfilelock | ||
const packages = { | ||
chardet: { | ||
hashes: [ | ||
'sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691', | ||
'sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae', | ||
], | ||
version: '==3.0.4', | ||
}, | ||
django: { | ||
editable: true, | ||
git: 'https://github.com/django/django.git', | ||
ref: '1.11.4001', | ||
}, | ||
'django-cms': { | ||
file: 'https://github.com/divio/django-cms/archive/release/3.4.x.zip', | ||
}, | ||
'discordlists-py': { | ||
git: 'https://github.com/HexCodeFFF/discordlists.py', | ||
ref: '2df5a2b62144b49774728efa8267d909a8a9787f', | ||
}, | ||
} | ||
|
||
it('throws if dependency not found in (in default object with data)', function () { | ||
expect(() => | ||
getDependencyVersion({ | ||
wantedDependency: 'requests', | ||
lockfileData: { | ||
default: packages, | ||
develop: {}, | ||
}, | ||
}) | ||
) | ||
.to.throw(InvalidParameter) | ||
.with.property('prettyMessage', 'default dependency not found') | ||
}) | ||
|
||
it('throws if dependency not found in (in empty dev object)', function () { | ||
expect(() => | ||
getDependencyVersion({ | ||
kind: 'dev', | ||
wantedDependency: 'requests', | ||
lockfileData: { | ||
default: packages, | ||
develop: {}, | ||
}, | ||
}) | ||
) | ||
.to.throw(InvalidParameter) | ||
.with.property('prettyMessage', 'dev dependency not found') | ||
}) | ||
|
||
it('tolerates missing keys', function () { | ||
expect( | ||
getDependencyVersion({ | ||
wantedDependency: 'chardet', | ||
lockfileData: { | ||
default: packages, | ||
}, | ||
}) | ||
).to.deep.equal({ version: '3.0.4' }) | ||
}) | ||
|
||
it('finds package in develop object', function () { | ||
expect( | ||
getDependencyVersion({ | ||
kind: 'dev', | ||
wantedDependency: 'chardet', | ||
lockfileData: { | ||
default: {}, | ||
develop: packages, | ||
}, | ||
}) | ||
).to.deep.equal({ version: '3.0.4' }) | ||
}) | ||
|
||
it('returns version if present', function () { | ||
expect( | ||
getDependencyVersion({ | ||
wantedDependency: 'chardet', | ||
lockfileData: { | ||
default: packages, | ||
develop: {}, | ||
}, | ||
}) | ||
).to.deep.equal({ version: '3.0.4' }) | ||
}) | ||
|
||
it('returns (complete) ref if ref is tag', function () { | ||
expect( | ||
getDependencyVersion({ | ||
wantedDependency: 'django', | ||
lockfileData: { | ||
default: packages, | ||
develop: {}, | ||
}, | ||
}) | ||
).to.deep.equal({ ref: '1.11.4001' }) | ||
}) | ||
|
||
it('returns truncated ref if ref is commit hash', function () { | ||
expect( | ||
getDependencyVersion({ | ||
wantedDependency: 'discordlists-py', | ||
lockfileData: { | ||
default: packages, | ||
develop: {}, | ||
}, | ||
}) | ||
).to.deep.equal({ ref: '2df5a2b' }) | ||
}) | ||
|
||
it('throws if no version or ref', function () { | ||
expect(() => | ||
getDependencyVersion({ | ||
wantedDependency: 'django-cms', | ||
lockfileData: { | ||
default: packages, | ||
develop: {}, | ||
}, | ||
}) | ||
) | ||
.to.throw(InvalidParameter) | ||
.with.property('prettyMessage', 'No version or ref for django-cms') | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i realize now I'm even more confused by what we were doing before. any idea why we were substringing from this range before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure I probably should have explained this more as there were 2 issues here:
shields/services/github/github-pipenv.tester.js
Line 10 in e4e7b09