import/github: Test it.

* Makefile.am (SCM_TESTS): Register new tests.
* guix/import/github.scm
  (%github-api): New variable.
  (fetch-releases-or-tags): Use the new variable.
* tests/import-github.scm: New file with tests.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Maxime Devos 2022-01-06 20:50:12 +00:00 committed by Ludovic Courtès
parent f8306a5019
commit 81f036bfd2
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 146 additions and 3 deletions

View file

@ -39,7 +39,10 @@
#:use-module (guix upstream)
#:use-module (guix http-client)
#:use-module (web uri)
#:export (%github-updater))
#:export (%github-api %github-updater))
;; For tests.
(define %github-api (make-parameter "https://api.github.com"))
(define (find-extension url)
"Return the extension of the archive e.g. '.tar.gz' given a URL, or
@ -150,11 +153,11 @@ tags show up in the \"Releases\" tab of the web UI. For instance,
'https://api.github.com/repos/aconchillo/guile-json/releases' returns the
empty list."
(define release-url
(string-append "https://api.github.com/repos/"
(string-append (%github-api) "/repos/"
(github-user-slash-repository url)
"/releases"))
(define tag-url
(string-append "https://api.github.com/repos/"
(string-append (%github-api) "/repos/"
(github-user-slash-repository url)
"/tags"))