@@ -24,30 +24,28 @@
#:use-module (guix http-client)
#:use-module (guix import github)
#:use-module (guix packages)
- #:use-module (guix tests)
+ #:use-module (guix tests http)
#:use-module (guix upstream)
+ #:use-module (web client)
+ #:use-module (web request)
+ #:use-module (web uri)
#:use-module (ice-9 match))
(test-begin "github")
(define (call-with-releases thunk tags releases)
- (mock ((guix http-client) http-fetch
- (lambda* (uri #:key headers)
- (unless (string-prefix? "mock://" uri)
- (error "the URI ~a should not be used" uri))
- (define components
- (string-split (substring uri 8) #\/))
- (pk 'stuff components headers)
- (define (scm->json-port scm)
- (open-input-string (scm->json-string scm)))
- (match components
- (("repos" "foo" "foomatics" "releases")
- (scm->json-port releases))
- (("repos" "foo" "foomatics" "tags")
- (scm->json-port tags))
- (rest (error "TODO ~a" rest)))))
- (parameterize ((%github-api "mock://"))
- (thunk))))
+ (with-http-server*
+ (lambda (request _)
+ (define resource (uri-path (request-uri request)))
+ (define components (string-split resource #\/))
+ (define json (match components
+ (("" "repos" "foo" "foomatics" "releases") releases)
+ (("" "repos" "foo" "foomatics" "tags") tags)
+ (rest (error "TODO ~a" rest))))
+ (values '() (lambda (port) (scm->json json port))))
+ (parameterize ((%github-api (%local-url* ""))
+ (current-http-proxy #false))
+ (thunk))))
;; Copied from tests/minetest.scm
(define (upstream-source->sexp upstream-source)