From patchwork Thu Jan 20 13:08:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 36647 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CD5DB27BBEA; Thu, 20 Jan 2022 18:06:11 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 765C627BBE9 for ; Thu, 20 Jan 2022 18:06:11 +0000 (GMT) Received: from localhost ([::1]:46374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAbp4-0001ZY-C4 for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 13:06:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXCX-0004EJ-8s for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXCV-0006SQ-9c for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXCV-0004t2-3j for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 4/9] tests/import-github: Run a HTTP server instead of mocking. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:10:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53389 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53389@debbugs.gnu.org Cc: ludo@gnu.org, Maxime Devos Received: via spool by 53389-submit@debbugs.gnu.org id=B53389.164268415818680 (code B ref 53389); Thu, 20 Jan 2022 13:10:03 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:18 +0000 Received: from localhost ([127.0.0.1]:56698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBi-0004r3-EG for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:09:18 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:42030) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004ou-4a for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:54 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118rNS; Thu, 20 Jan 2022 14:08:51 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:44 +0000 Message-Id: <20220120130849.292178-4-maximedevos@telenet.be> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220120130849.292178-1-maximedevos@telenet.be> References: <20220120130849.292178-1-maximedevos@telenet.be> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1642684131; bh=7sjWEY1uigWnXHXrDjfkJlPOHumdUX4dZusyrLHTkZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ffvx/R1utHKCoKPkb6Bo1W7CJunI7QRoHPTHtaC/yk9BJC0rClG2+00uTxDx29GkQ zmWQNA5jJHvut2NsjQ+IjJOWa736HQOEj9gF/03knHSiht5Fl7Tdfj8U462zi4EXn6 74TNG/ayya7Z3mRO0jgU0lHBWG3OekyvWdb1Bx3IAIL+QNgIDAfggfNsiM3tljHNCf evCZ7B3stf5hi18HYTh3NQRQe+2U/EyZptZD2GJx5ohA+yKVlczdOcj7MNXpTRXZYV yHJoVslx+imo22r3tV/lzHsVvT5uNKNla6H2jkogObA8Q2tlBuGQkhZV28gBep5ukf cR1y4Fcim69+w== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Fixes: * tests/import-github.scm (call-with-releases): Run a HTTP server instead of mocking. Suggested-by: Ludovic Courtès --- 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)