[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#53389] [PATCH 4/9] tests/import-github: Run a HTTP server instead o
From: |
Maxime Devos |
Subject: |
[bug#53389] [PATCH 4/9] tests/import-github: Run a HTTP server instead of mocking. |
Date: |
Thu, 20 Jan 2022 13:08:44 +0000 |
Fixes: <https://issues.guix.gnu.org/53060#3>
* tests/import-github.scm (call-with-releases): Run a HTTP server instead of
mocking.
Suggested-by: Ludovic Courtès <ludo@gnu.org>
---
tests/import-github.scm | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/tests/import-github.scm b/tests/import-github.scm
index 979a0fc12b..f6985fac55 100644
--- a/tests/import-github.scm
+++ b/tests/import-github.scm
@@ -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)
--
2.30.2
- [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 1/9] tests: Support arbitrary HTTP request handlers., Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 2/9] tests: Generalise %local-url., Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 3/9] tests/minetest: Run a HTTP server instead of mocking., Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 8/9] tests/cpan: Verify URIs., Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 5/9] tests/cpan: Do not hard code a HTTP port., Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 6/9] tests/lint: Do not assume the next port is free., Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 7/9] tests: Allow checking the URI of a HTTP request., Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 9/9] tests/challenge: Do not hard code HTTP ports., Maxime Devos, 2022/01/20
- [bug#53389] [PATCH 4/9] tests/import-github: Run a HTTP server instead of mocking.,
Maxime Devos <=
- [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Ludovic Courtès, 2022/01/22
- [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Maxime Devos, 2022/01/22
- [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Ludovic Courtès, 2022/01/25
- [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Maxime Devos, 2022/01/25
- [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Maxime Devos, 2022/01/22
- [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Maxime Devos, 2022/01/22
- [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Maxime Devos, 2022/01/22
- [bug#53389] [PATCH 1/9] tests: Support arbitrary HTTP request handlers., Maxime Devos, 2022/01/22
[bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,, Ludovic Courtès, 2022/01/20