diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2024-01-26 14:41:37 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2024-02-12 12:03:53 +0100 |
| commit | 29f3089c841f00144f24f5c32296aebf22d752cc (patch) | |
| tree | 097248568c3a7a737be1d210e02fd03fb9111f1f /tests | |
| parent | 1b72e1430794fd09bb2be1d72f482a40c0f9196e (diff) | |
lint: archival: Check with ‘lookup-directory-by-nar-hash’.
While this method is new and nar-sha256 ExtIDs are currently available
only for new visits, it is fundamentally more reliable than the other
methods, which is why it comes first.
* guix/lint.scm (check-archival)[lookup-by-nar-hash]: New procedure.
Call ‘lookup-by-nar-hash’ before the other lookup methods.
* tests/lint.scm ("archival: content available")
("archival: content unavailable but disarchive available")
("archival: missing revision")
("archival: revision available"): Add a 404 response corresponding to
the ‘lookup-external-id’ request.
* tests/lint.scm ("archival: nar-sha256 extid available"): New test.
Change-Id: I4a81d6e022a3b72e6484726549d7fbae627f8e73
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lint.scm | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/tests/lint.scm b/tests/lint.scm index a52a82237b6..87213fcc78a 100644 --- a/tests/lint.scm +++ b/tests/lint.scm | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2012, 2013 Cyril Roelandt <tipecaml@gmail.com> | 2 | ;;; Copyright © 2012, 2013 Cyril Roelandt <tipecaml@gmail.com> |
| 3 | ;;; Copyright © 2014, 2015, 2016 Eric Bavier <bavier@member.fsf.org> | 3 | ;;; Copyright © 2014, 2015, 2016 Eric Bavier <bavier@member.fsf.org> |
| 4 | ;;; Copyright © 2014-2023 Ludovic Courtès <ludo@gnu.org> | 4 | ;;; Copyright © 2014-2024 Ludovic Courtès <ludo@gnu.org> |
| 5 | ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org> | 5 | ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org> |
| 6 | ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> | 6 | ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> |
| 7 | ;;; Copyright © 2017 Alex Kost <alezost@gmail.com> | 7 | ;;; Copyright © 2017 Alex Kost <alezost@gmail.com> |
| @@ -1358,7 +1358,8 @@ | |||
| 1358 | ;; https://archive.softwareheritage.org/api/1/content/ | 1358 | ;; https://archive.softwareheritage.org/api/1/content/ |
| 1359 | (content "{ \"checksums\": {}, \"data_url\": \"xyz\", | 1359 | (content "{ \"checksums\": {}, \"data_url\": \"xyz\", |
| 1360 | \"length\": 42 }")) | 1360 | \"length\": 42 }")) |
| 1361 | (with-http-server `((200 ,content)) | 1361 | (with-http-server `((404 "") ;extid |
| 1362 | (200 ,content)) | ||
| 1362 | (parameterize ((%swh-base-url (%local-url))) | 1363 | (parameterize ((%swh-base-url (%local-url))) |
| 1363 | (check-archival (dummy-package "x" (source origin))))))) | 1364 | (check-archival (dummy-package "x" (source origin))))))) |
| 1364 | 1365 | ||
| @@ -1378,7 +1379,8 @@ | |||
| 1378 | \"type\": \"file\", | 1379 | \"type\": \"file\", |
| 1379 | \"name\": \"README\" | 1380 | \"name\": \"README\" |
| 1380 | \"length\": 42 } ]")) | 1381 | \"length\": 42 } ]")) |
| 1381 | (with-http-server `((404 "") ;lookup-content | 1382 | (with-http-server `((404 "") ;lookup-directory-by-nar-hash |
| 1383 | (404 "") ;lookup-content | ||
| 1382 | (200 ,disarchive) ;Disarchive database lookup | 1384 | (200 ,disarchive) ;Disarchive database lookup |
| 1383 | (200 ,directory)) ;lookup-directory | 1385 | (200 ,directory)) ;lookup-directory |
| 1384 | (mock ((guix download) %disarchive-mirrors (list (%local-url))) | 1386 | (mock ((guix download) %disarchive-mirrors (list (%local-url))) |
| @@ -1397,7 +1399,8 @@ | |||
| 1397 | \"save_request_date\": \"2014-11-17T22:09:38+01:00\", | 1399 | \"save_request_date\": \"2014-11-17T22:09:38+01:00\", |
| 1398 | \"save_request_status\": \"accepted\", | 1400 | \"save_request_status\": \"accepted\", |
| 1399 | \"save_task_status\": \"scheduled\" }") | 1401 | \"save_task_status\": \"scheduled\" }") |
| 1400 | (warnings (with-http-server `((404 "No revision.") ;lookup-revision | 1402 | (warnings (with-http-server `((404 "No extid.") ;lookup-directory-by-nar-hash |
| 1403 | (404 "No revision.") ;lookup-revision | ||
| 1401 | (404 "No origin.") ;lookup-origin | 1404 | (404 "No origin.") ;lookup-origin |
| 1402 | (200 ,save)) ;save-origin | 1405 | (200 ,save)) ;save-origin |
| 1403 | (parameterize ((%swh-base-url (%local-url))) | 1406 | (parameterize ((%swh-base-url (%local-url))) |
| @@ -1415,7 +1418,27 @@ | |||
| 1415 | ;; https://archive.softwareheritage.org/api/1/revision/ | 1418 | ;; https://archive.softwareheritage.org/api/1/revision/ |
| 1416 | (revision "{ \"author\": {}, \"parents\": [], | 1419 | (revision "{ \"author\": {}, \"parents\": [], |
| 1417 | \"date\": \"2014-11-17T22:09:38+01:00\" }")) | 1420 | \"date\": \"2014-11-17T22:09:38+01:00\" }")) |
| 1418 | (with-http-server `((200 ,revision)) | 1421 | (with-http-server `((404 "No directory.") ;lookup-directory-by-nar-hash |
| 1422 | (200 ,revision)) | ||
| 1423 | (parameterize ((%swh-base-url (%local-url))) | ||
| 1424 | (check-archival (dummy-package "x" (source origin))))))) | ||
| 1425 | |||
| 1426 | (test-equal "archival: nar-sha256 extid available" | ||
| 1427 | '() | ||
| 1428 | (let* ((origin (origin | ||
| 1429 | (method git-fetch) | ||
| 1430 | (uri (git-reference | ||
| 1431 | (url "http://example.org/foo.git") | ||
| 1432 | (commit "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))) | ||
| 1433 | (sha256 (make-bytevector 32)))) | ||
| 1434 | ;; https://archive.softwareheritage.org/api/1/extid/doc/ | ||
| 1435 | (extid "{ \"extid_type\": \"nar-sha256\", | ||
| 1436 | \"extid\": \"1234\", | ||
| 1437 | \"extid_version\": 0, | ||
| 1438 | \"target\": \"swh:1:dir:cabba93\", | ||
| 1439 | \"target_url\": \"boo\" | ||
| 1440 | }")) | ||
| 1441 | (with-http-server `((200 ,extid)) | ||
| 1419 | (parameterize ((%swh-base-url (%local-url))) | 1442 | (parameterize ((%swh-base-url (%local-url))) |
| 1420 | (check-archival (dummy-package "x" (source origin))))))) | 1443 | (check-archival (dummy-package "x" (source origin))))))) |
| 1421 | 1444 | ||
