diff --git a/swh/loader/package/loader.py b/swh/loader/package/loader.py --- a/swh/loader/package/loader.py +++ b/swh/loader/package/loader.py @@ -341,7 +341,7 @@ if not tmp_revisions: # We could not load any revisions; fail completely - status_visit = 'failed' + status_visit = 'partial' status_load = 'failed' return finalize_visit() diff --git a/swh/loader/package/npm/tests/data/https_replicate.npmjs.com/catify b/swh/loader/package/npm/tests/data/https_replicate.npmjs.com/catify new file mode 100644 --- /dev/null +++ b/swh/loader/package/npm/tests/data/https_replicate.npmjs.com/catify @@ -0,0 +1,20 @@ +{ + "_id": "catify", + "_rev": "1-67058d22a9c3398032ee164ad49cd3db", + "name": "catify", + "time": { + "modified": "2017-08-23T00:06:59.080Z", + "created": "2014-04-03T23:11:33.508Z" + }, + "maintainers": [ + { + "email": "shawn@andgoodwork.com", + "name": "shawnhilgart" + } + ], + "description": "Middleware that redirects users at random to a cat gif.", + "readme": "catify\n======\n\nMiddleware that redirects users at random to a cat gif.\n\n## Usage\n\n```javascript\n\nvar catify = require('catify');\nvar express = require('express');\nvar app = new express();\n\napp.use(catify(50)); // catify accepts one argument for probability\n\n```\n\n", + "versions": {}, + "dist-tags": {}, + "readmeFilename": "" +} diff --git a/swh/loader/package/npm/tests/test_npm.py b/swh/loader/package/npm/tests/test_npm.py --- a/swh/loader/package/npm/tests/test_npm.py +++ b/swh/loader/package/npm/tests/test_npm.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019 The Software Heritage developers +# Copyright (C) 2019-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -589,3 +589,20 @@ origin_visit = list(loader.storage.origin_visit_get(url))[-1] assert origin_visit['status'] == 'full' assert origin_visit['type'] == 'npm' + + +def test_npm_no_artifact(swh_config, requests_mock_datadir): + """If no artifacts at all is found for origin, the visit fails completely + + """ + package = 'catify' + url = package_url(package) + loader = NpmLoader(url) + actual_load_status = loader.load() + assert actual_load_status == { + 'status': 'failed', + } + + origin_visit = loader.storage.origin_visit_get_latest(url) + assert origin_visit['status'] == 'partial' + assert origin_visit['type'] == 'npm'