From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IEr5I5/HvmVVBQEAqHPOHw:P1 (envelope-from ) for ; Sun, 04 Feb 2024 00:09:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id IEr5I5/HvmVVBQEAqHPOHw (envelope-from ) for ; Sun, 04 Feb 2024 00:09:19 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1707001759; a=rsa-sha256; cv=none; b=i2uZqgna2gXBy15NocuZNr1LL2z7zz+FvEgmWspzlUsiaOakUEktVQmhYFt6Zh1WD0dnoE Ywico3iJndl4i4JY/kEdbo9vaOv3V7e1m/OF6yJx7cKbEAOJQzAJV0QRVDKj0fhwzdfvHQ 8UvyBxQVIZpA5wDJF4hVLDHY/cSq2vUUrU6JPsPIlXI3EoyELQhGCtrWn+TKL9Pj4hpqWE FPt0VySFSF1n14bMZ9qw7qzmKe7NFXQTUMbk1yWqnpExReEB/24Ji3t+TfqNVPqLlkmPYp ru16XfkbDpKkH094gY468JmGB87JsUtSq/I6YivzB9+9FHsYujEoGR1rFAo06g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1707001759; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=9sKK1OFC+z8VNG0RUDa2tDlWNyCLZOB2+zxAPh5NTkU=; b=LFAfap5QV698PRoFX+a4clqhoHKcD2XII4+GVsbE1aexePQeZSDr8hZ1yoNMQiyLbd1vBp wPb2Ps5W1TLquFcC1OzRY4XYq6mGYGSjsuCQrI8tc2eNAjYhquNJN30M/Pvwa05QGkoL29 xiXRpcgfwYXvdaxQrRRQGmyBLYNFtfNtzrWI9RBLx9RmlW4I5VmN9Mq2ZAUyMt1ar01b5m 09fi5syrwcCO1OITBqGNClTHfMahgGCcNSGTcAfG29vTKSa79P7yuqPIS+VtLwf5Hap/2E oYN+V/vtKko/CdTv8Re+Qx4KC55Ea2xjFm1yPpoUugBRyqn8AcEmLm+OplVnvw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 27804739D2 for ; Sun, 4 Feb 2024 00:09:19 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWP83-0008Cj-RA; Sat, 03 Feb 2024 18:08:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWP81-0008BS-FZ for guix-patches@gnu.org; Sat, 03 Feb 2024 18:08:53 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWP81-0008EV-7N for guix-patches@gnu.org; Sat, 03 Feb 2024 18:08:53 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rWP8C-0001Hs-FA for guix-patches@gnu.org; Sat, 03 Feb 2024 18:09:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#62202] [PATCH v4 6/6] tests: juliahub: Add unit tests for (guix import juliahub). Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 03 Feb 2024 23:09:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62202 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch moreinfo To: 62202@debbugs.gnu.org Cc: ngraves@ngraves.fr, zimoun.toutoune@gmail.com Received: via spool by 62202-submit@debbugs.gnu.org id=B62202.17070017144873 (code B ref 62202); Sat, 03 Feb 2024 23:09:04 +0000 Received: (at 62202) by debbugs.gnu.org; 3 Feb 2024 23:08:34 +0000 Received: from localhost ([127.0.0.1]:47256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWP7h-0001GS-Jh for submit@debbugs.gnu.org; Sat, 03 Feb 2024 18:08:34 -0500 Received: from 12.mo550.mail-out.ovh.net ([87.98.162.229]:34175) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWP7e-0001Fk-Fy for 62202@debbugs.gnu.org; Sat, 03 Feb 2024 18:08:32 -0500 Received: from director2.ghost.mail-out.ovh.net (unknown [10.109.148.79]) by mo550.mail-out.ovh.net (Postfix) with ESMTP id 2257E283D2 for <62202@debbugs.gnu.org>; Sat, 3 Feb 2024 23:08:17 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-wmfjk (unknown [10.110.96.132]) by director2.ghost.mail-out.ovh.net (Postfix) with ESMTPS id D4AA11FD2B; Sat, 3 Feb 2024 23:08:16 +0000 (UTC) Received: from ngraves.fr ([37.59.142.99]) by ghost-submission-6684bf9d7b-wmfjk with ESMTPSA id RY8lMGDHvmVLPhsAW0a7IA (envelope-from ); Sat, 03 Feb 2024 23:08:16 +0000 X-OVh-ClientIp: 81.67.146.208 Date: Sun, 4 Feb 2024 00:07:16 +0100 Message-ID: <20240203230807.25751-6-ngraves@ngraves.fr> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240203230807.25751-1-ngraves@ngraves.fr> References: <20240203230807.25751-1-ngraves@ngraves.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 14366764287976268391 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrfedujedgtdejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpedvvddvgedtudffgeegfeeluddtieevvdevuefgledtveduteetgedutdfgleffueenucffohhmrghinhepghhnuhdrohhrghdphhhtthhpqdhfvghttghhuhhnvgigphgvtghtvgguuhhrlhhurhhluggvfhhinhgvmhhotghkqdhhthhtphdqghgvthhtvghsthgtrghsvghlrghmsggurghurhhlrdhrvghsthdpghhithhhuhgsrdgtohhmpdhrvghpohhrthdrmhgupdgrmhgriihonhgrfihsrdgtohhmpdhlihgtvghnshgvpghurhhlrdguohgtshdplhhitggvnhhsvgdrmhgupdhjuhhlihgrhhhusgdrtghomhdpghhithhhuhgsuhhsvghrtghonhhtvghnthdrtghomhdpthhomhhlrdhnrghmvgenucfkphepuddvjedrtddrtddruddpkedurdeijedrudegiedrvddtkedpfeejrdehledrudegvddrleelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqedpnhgspghrtg hpthhtohepuddprhgtphhtthhopeeivddvtddvseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehhedtpdhmohguvgepshhmthhpohhuth 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches From: Nicolas Graves via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx10.migadu.com X-Spam-Score: -7.17 X-Migadu-Queue-Id: 27804739D2 X-Migadu-Spam-Score: -7.17 X-TUID: OuvyMAz+LNK8 * tests/juliahub.scm : Add unit tests juliahub-redirect, julia-general-registry-parsing, juliahub-fetch. Change-Id: Ief5133b49a15d0bfc72bb357321126d296ba2802 --- tests/juliahub.scm | 185 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 tests/juliahub.scm diff --git a/tests/juliahub.scm b/tests/juliahub.scm new file mode 100644 index 0000000000..21fdc3a4eb --- /dev/null +++ b/tests/juliahub.scm @@ -0,0 +1,185 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2024 Nicolas Graves +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +;;; Summary +;; Tests for guix/import/juliahub.scm + +(define-module (tests-import-juliahub) + #:use-module (guix base32) + #:use-module (json) + #:use-module (guix import juliahub) + #:use-module (guix import utils) + #:use-module ((guix utils) #:select (call-with-temporary-directory)) + #:use-module (guix tests) + #:use-module (ice-9 match) + #:use-module (srfi srfi-19) + #:use-module (srfi srfi-64) + #:use-module (srfi srfi-71) + #:use-module (web response)) + +;; XXX: Copied from tests/go.scm + +(define (mock-http-fetch testcase) + (lambda (url . rest) + (let ((body (assoc-ref testcase url))) + (if body + (open-input-string body) + (error "mocked http-fetch Unexpected URL: " url))))) + +(define (mock-http-get testcase) + (lambda (url . rest) + (let ((body (assoc-ref testcase url)) + (response-header + (build-response + #:version '(1 . 1) + #:code 200 + #:reason-phrase "Ok" + #:headers `( + (content-type text/html (charset . "utf-8")) + (date . ,(make-date 0 10 58 12 6 3 2021 0)) + (transfer-encoding (chunked))) + #:port #f + #:validate-headers? #t))) + (if body + (values response-header body) + (error "mocked http-get Unexpected URL: " url))))) + +;; Mock an empty directory by replacing hash. +(define* (mock-git->origin repo-url ref #:key (ref->commit #f)) + (let* ((version (if (pair? ref) + (cdr ref) + #f)) + (vcommit (match ref->commit + (#t commit) + (#f version) + ((? procedure?) (ref->commit version)) + (_ #f)))) + `(origin + (method git-fetch) + (uri (git-reference + (url ,(and (not (eq? repo-url 'null)) repo-url)) + (commit ,vcommit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5"))))) + +;; Fixtures. + +(define fixture-pkg.json + (scm->json-string + `(("hosted_uri" . "https://git.savannah.gnu.org/cgit/MyPackage.git") + ("installable" . "missing") + ("license" . "GPL-3.0") + ("tags" . #("my-tag")) + ("uuid" . "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa") + ("url" . "https://git.savannah.gnu.org/cgit/MyPackage.git") + ("contributors" . #((("url" . "https://github.com/me") ("type" . "User") ("contributions" . 1) ("name" . "me")))) + ("success" . #t) + ("reversedeps" . #()) + ("pkgeval" + ("report_url" . "https://github.com/JuliaCI/NanosoldierReports/blob/master/pkgeval/by_date/2024-02/01/report.md") + ("version" ("minor" . 18) ("patch" . 1) ("build" . #()) ("prerelease" . #()) ("major" . 1)) + ("reason" . "time_limit") + ("log_url" . "https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_date/2024-02/01/MyPackage.jl.primary.log") + ("status" . "fail") + ("duration" . 0)) + ("stargazers_count" . 0) + ("deps" . #((("slug" . "3FQLY") + ("registry" . "") + ("versions" . #("0.0.0" "1.6.0-1")) + ("uuid" . "de0858da-6303-5e67-8744-51eddeeeb8d7") + ("name" . "Printf") + ("direct" . #t)) + (("slug" . "SIw1t") + ("registry" . "") + ("versions" . #("*" "0.0.0" "1")) + ("uuid" . "cf7118a7-6976-5b1a-9a39-7adc72f591a4") + ("name" . "UUIDs") + ("direct" . #f)) + (("slug" . "THl1k") + ("registry" . "General") + ("versions" . #("0.7" "1" "1-1.10" "1.0-1.5" "1.3.0-1" "1.6.0-1" "1.9.0-1" "1.9.4-1")) + ("uuid" . "1222c4b2-2114-5bfd-aeef-88e4692bbb3e") + ("name" . "julia") + ("direct" . #f)) + (("slug" . "THl1k") + ("registry" . "General") + ("versions" . #("1.6.0-1")) + ("uuid" . "1222c4b2-2114-5bfd-aeef-88e4692bbb3e") + ("name" . "julia") + ("direct" . #t)))) + ("description" . "My description") + ("version" . "1.0.0") + ("documenter_errored" . "missing") + ("slug" . "MySlg") + ("owner" . "me") + ("release_date" . "Feb 2024") + ("name" . "MyPackage.jl") + ("readme" . "My readme") + ("homepage" . "https://git.savannah.gnu.org/cgit/MyPackage.git") + ("doctype" . "hosted") + ("license_url" . "/docs/MyPackage/MySlg/1.0.0/_packagesource/LICENSE.md")))) + +(define fixtures-juliahub-check-test + `(("https://docs.juliahub.com/MyPackage/" . "\ + + +") + ("https://raw.githubusercontent.com/JuliaRegistries/General/master\ +/M/MyPackage/Package.toml" . "\ +name = \"MyPackage\" +uuid = \"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa\" +repo = \"https://git.savannah.gnu.org/cgit/MyPackage.git\" +") + ("https://docs.juliahub.com/MyPackage/MySlg/1.0.0/pkg.json" . ,fixture-pkg.json))) + +(test-begin "juliahub") + +;;; Unit tests for (guix import juliahub) + +(test-equal "juliahub-redirect" + "https://docs.juliahub.com/MyPackage/MySlg/1.0.0/" + (mock ((web client) http-get + (mock-http-get fixtures-juliahub-check-test)) + (mock ((guix http-client) http-fetch + (mock-http-fetch fixtures-juliahub-check-test)) + ((@@ (guix import juliahub) juliahub-url) "MyPackage")))) + +(test-equal "julia-general-registry-parsing" + "https://git.savannah.gnu.org/cgit/MyPackage.git" + (mock ((web client) http-get + (mock-http-get fixtures-juliahub-check-test)) + (mock ((guix http-client) http-fetch + (mock-http-fetch fixtures-juliahub-check-test)) + (assoc-ref + ((@@ (guix import juliahub) ini-fetch) + ((@@ (guix import juliahub) general-url) "MyPackage" "Package.toml")) + 'repo)))) + +(test-equal "juliahub-fetch" + #t + (mock ((web client) http-get + (mock-http-get fixtures-juliahub-check-test)) + (mock ((guix http-client) http-fetch + (mock-http-fetch fixtures-juliahub-check-test)) + (mock ((guix import utils) git->origin mock-git->origin) + ((@@ (guix import juliahub) juliahub-package?) + ((@@ (guix import juliahub) juliahub-fetch) "MyPackage")))))) + +(test-end "juliahub") -- 2.41.0