mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
tests: Adjust to (guix import github) changes.
This is a followup to a8d3033da6
.
* tests/import-github.scm (call-with-releases): Mock
'open-connection-for-uri'.
This commit is contained in:
parent
34ba6e0616
commit
667f21aea0
1 changed files with 26 additions and 17 deletions
|
@ -26,17 +26,26 @@ (define-module (test-import-github)
|
|||
#:use-module (guix packages)
|
||||
#:use-module (guix tests)
|
||||
#:use-module (guix upstream)
|
||||
#:use-module (web uri)
|
||||
#:use-module (ice-9 match))
|
||||
|
||||
(test-begin "github")
|
||||
|
||||
(define (call-with-releases thunk tags releases)
|
||||
(mock ((guix build download) open-connection-for-uri
|
||||
(lambda _
|
||||
;; Return a fake socket.
|
||||
(%make-void-port "w+0")))
|
||||
(mock ((guix http-client) http-fetch
|
||||
(lambda* (uri #:key headers)
|
||||
(unless (string-prefix? "mock://" uri)
|
||||
(lambda* (uri #:key headers #:allow-other-keys)
|
||||
(let ((uri (if (string? uri)
|
||||
(string->uri uri)
|
||||
uri)))
|
||||
(unless (eq? 'mock (uri-scheme uri))
|
||||
(error "the URI ~a should not be used" uri))
|
||||
(define components
|
||||
(string-split (substring uri 8) #\/))
|
||||
(string-tokenize (uri-path uri)
|
||||
(char-set-complement (char-set #\/))))
|
||||
(pk 'stuff components headers)
|
||||
(define (scm->json-port scm)
|
||||
(open-input-string (scm->json-string scm)))
|
||||
|
@ -45,9 +54,9 @@ (define (scm->json-port scm)
|
|||
(scm->json-port releases))
|
||||
(("repos" "foo" "foomatics" "tags")
|
||||
(scm->json-port tags))
|
||||
(rest (error "TODO ~a" rest)))))
|
||||
(rest (error "TODO ~a" rest))))))
|
||||
(parameterize ((%github-api "mock://"))
|
||||
(thunk))))
|
||||
(thunk)))))
|
||||
|
||||
;; Copied from tests/minetest.scm
|
||||
(define (upstream-source->sexp upstream-source)
|
||||
|
|
Loading…
Reference in a new issue