summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-05-15 12:19:03 +0200
committerLudovic Courtès <ludo@gnu.org>2021-05-22 23:13:11 +0200
commitbc4d81d267830a3b1ccb63198f4100cc836e4e4e (patch)
tree7ef8268c2920f0bb0f43d348183c3ffd6d96d39f /tests
parentdac6c21623475dbd1fa9679e33649eba461dd6b2 (diff)
lint: archival: Lookup content in Disarchive database.
* guix/lint.scm (lookup-disarchive-spec): New procedure. (check-archival): When 'lookup-content' returns #f, call 'lookup-disarchive-spec'. Call 'lookup-directory' on the result of 'lookup-directory'. * guix/download.scm (%disarchive-mirrors): Make public. * tests/lint.scm ("archival: missing content"): Set '%disarchive-mirrors'. ("archival: content unavailable but disarchive available"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/lint.scm34
1 files changed, 30 insertions, 4 deletions
diff --git a/tests/lint.scm b/tests/lint.scm
index a2c86651424..d54fafc1d2b 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, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> 4;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 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>
@@ -1008,10 +1008,13 @@
1008 (method url-fetch) 1008 (method url-fetch)
1009 (uri "http://example.org/foo.tgz") 1009 (uri "http://example.org/foo.tgz")
1010 (sha256 (make-bytevector 32)))) 1010 (sha256 (make-bytevector 32))))
1011 (warnings (with-http-server '((404 "Not archived.")) 1011 (warnings (with-http-server '((404 "Not archived.")
1012 (404 "Not in Disarchive database."))
1012 (parameterize ((%swh-base-url (%local-url))) 1013 (parameterize ((%swh-base-url (%local-url)))
1013 (check-archival (dummy-package "x" 1014 (mock ((guix download) %disarchive-mirrors
1014 (source origin))))))) 1015 (list (%local-url)))
1016 (check-archival (dummy-package "x"
1017 (source origin))))))))
1015 (warning-contains? "not archived" warnings))) 1018 (warning-contains? "not archived" warnings)))
1016 1019
1017(test-equal "archival: content available" 1020(test-equal "archival: content available"
@@ -1027,6 +1030,29 @@
1027 (parameterize ((%swh-base-url (%local-url))) 1030 (parameterize ((%swh-base-url (%local-url)))
1028 (check-archival (dummy-package "x" (source origin))))))) 1031 (check-archival (dummy-package "x" (source origin)))))))
1029 1032
1033(test-equal "archival: content unavailable but disarchive available"
1034 '()
1035 (let* ((origin (origin
1036 (method url-fetch)
1037 (uri "http://example.org/foo.tgz")
1038 (sha256 (make-bytevector 32))))
1039 (disarchive (object->string
1040 '(disarchive (version 0)
1041 ...
1042 "swh:1:dir:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")))
1043 ;; https://archive.softwareheritage.org/api/1/directory/
1044 (directory "[ { \"checksums\": {},
1045 \"dir_id\": \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
1046 \"type\": \"file\",
1047 \"name\": \"README\"
1048 \"length\": 42 } ]"))
1049 (with-http-server `((404 "") ;lookup-content
1050 (200 ,disarchive) ;Disarchive database lookup
1051 (200 ,directory)) ;lookup-directory
1052 (mock ((guix download) %disarchive-mirrors (list (%local-url)))
1053 (parameterize ((%swh-base-url (%local-url)))
1054 (check-archival (dummy-package "x" (source origin))))))))
1055
1030(test-assert "archival: missing revision" 1056(test-assert "archival: missing revision"
1031 (let* ((origin (origin 1057 (let* ((origin (origin
1032 (method git-fetch) 1058 (method git-fetch)