-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Use direct endpoint instead of search to find repository URL from n…
…pm database (#4118) * Update endpoint used when getting repo from npm to solve #3166 Signed-off-by: aklevans <[email protected]> * Update test files to account for endpoint change when getting repo from npm Signed-off-by: aklevans <[email protected]> * Fix linter issues Signed-off-by: aklevans <[email protected]> * Added unit tests for #3166 and #2441 Signed-off-by: aklevans <[email protected]> * fix linter issues and reduce mock json output in package_manager_test to only include necessary data Signed-off-by: aklevans <[email protected]> * fix linter issues in package_managers.go Signed-off-by: aklevans <[email protected]> * convert windows line breaks to linux Signed-off-by: aklevans <[email protected]> * reduce test case size, still has windows line breaks Signed-off-by: aklevans <[email protected]> * Fix unit tests Signed-off-by: aklevans <[email protected]> * attempt linter fix Signed-off-by: aklevans <[email protected]> * Fix linter issues stemming from windows line breaks Signed-off-by: aklevans <[email protected]> * Remove magic number and rename variable to be more accurate Signed-off-by: aklevans <[email protected]> --------- Signed-off-by: aklevans <[email protected]> Signed-off-by: aklevans <[email protected]>
- Loading branch information
Showing
2 changed files
with
51 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,53 +48,48 @@ func Test_fetchGitRepositoryFromNPM(t *testing.T) { | |
packageName: "npm-package", | ||
result: ` | ||
{ | ||
"objects": [ | ||
{ | ||
"package": { | ||
"name": "@pulumi/pulumi", | ||
"scope": "pulumi", | ||
"version": "3.26.0", | ||
"description": "Pulumi's Node.js SDK", | ||
"date": "2022-03-09T14:05:40.682Z", | ||
"links": { | ||
"homepage": "https://github.com/pulumi/pulumi#readme", | ||
"repository": "https://github.com/pulumi/pulumi", | ||
"bugs": "https://github.com/pulumi/pulumi/issues" | ||
}, | ||
"publisher": { | ||
"username": "pulumi-bot", | ||
"email": "[email protected]" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"username": "joeduffy", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"username": "pulumi-bot", | ||
"email": "[email protected]" | ||
} | ||
] | ||
}, | ||
"score": { | ||
"final": 0.4056031974977145, | ||
"detail": { | ||
"quality": 0.7308571951451065, | ||
"popularity": 0.19908392082147397, | ||
"maintenance": 0.3333333333333333 | ||
} | ||
}, | ||
"searchScore": 0.00090895034 | ||
} | ||
], | ||
"total": 380, | ||
"time": "Wed Mar 09 2022 18:11:10 GMT+0000 (Coordinated Universal Time)" | ||
"name": "@pulumi/pulumi", | ||
"version": "3.116.1", | ||
"description": "Pulumi's Node.js SDK", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/pulumi/pulumi.git", | ||
"directory": "sdk/nodejs" | ||
} | ||
} | ||
`, | ||
}, | ||
want: "https://github.com/pulumi/pulumi", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "fetchGitRepositoryFromNPM", | ||
|
||
args: args{ | ||
packageName: "left-pad", | ||
result: ` | ||
{ | ||
"name": "left-pad", | ||
"version": "1.3.0", | ||
"description": "String left pad", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"test": "node test", | ||
"bench": "node perf/perf.js" | ||
}, | ||
"repository": { | ||
"url": "git+ssh://[email protected]/stevemao/left-pad.git", | ||
"type": "git" | ||
} | ||
} | ||
`, | ||
}, | ||
want: "ssh://[email protected]/stevemao/left-pad", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "fetchGitRepositoryFromNPM_error", | ||
|
||
|
@@ -109,8 +104,10 @@ func Test_fetchGitRepositoryFromNPM(t *testing.T) { | |
name: "fetchGitRepositoryFromNPM_error", | ||
|
||
args: args{ | ||
packageName: "npm-package", | ||
result: "foo", | ||
packageName: "https://github.com/airbnb/lottie-web", | ||
result: ` | ||
{"code":"ResourceNotFound","message":"/https:/github.com/airbnb/lottie-web does not exist"} | ||
`, | ||
}, | ||
want: "", | ||
wantErr: true, | ||
|