all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Graves via Guix-patches via <guix-patches@gnu.org>
To: 62202@debbugs.gnu.org
Cc: ngraves@ngraves.fr, zimoun.toutoune@gmail.com
Subject: [bug#62202] [PATCH v4 6/6] tests: juliahub: Add unit tests for (guix import juliahub).
Date: Sun,  4 Feb 2024 00:07:16 +0100	[thread overview]
Message-ID: <20240203230807.25751-6-ngraves@ngraves.fr> (raw)
In-Reply-To: <20240203230807.25751-1-ngraves@ngraves.fr>

* 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 <ngraves@ngraves.fr>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+;;; 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/" . "\
+<head>
+<meta http-equiv=\"refresh\" content=\"0; url=MySlg/1.0.0\" />
+</head>")
+    ("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





  parent reply	other threads:[~2024-02-03 23:09 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15 12:47 [bug#62202] [PATCH 0/21] Juliahub import script Nicolas Graves via Guix-patches via
2023-03-15 12:51 ` [bug#62202] [PATCH 01/21] import: juliahub: first script draft Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 02/21] import: utils: Change git->origin function to git->origin+version Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 03/21] import: juliahub: Add support for native-inputs Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 04/21] import: juliahub: Correct source parsing Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 05/21] import: juliahub: Add indirect dependencies Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 06/21] import: juliahub: Add updater and recursive-importer Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 07/21] import: juliahub: Filter out julia stdlibs Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 08/21] import: juliahub: Simplify juliahub dependency management Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 09/21] import: juliahub: Improve " Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 10/21] import: juliahub: Add functions to parse the git repo for a git tag Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 11/21] import: juliahub: Improve test dependencies parsing Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 12/21] import: juliahub: Handle the case where we have a subdirectory Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 13/21] import: juliahub: Add support for versions for juliahub-fetch Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 14/21] import: juliahub: Filter out stdlibs from test-dependencies Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 15/21] import: juliahub: More robust toml regex parser Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 16/21] import: juliahub: Beautify description Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 17/21] import: juliahub: Fix license management Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 18/21] import: juliahub: Fix version management Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 19/21] import: juliahub: Fix undefined homepages Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 20/21] import: utils: Rule out texinfo common syntax from @ escape Nicolas Graves via Guix-patches via
2023-03-15 12:51   ` [bug#62202] [PATCH 21/21] import: juliahub: output package names as symbols Nicolas Graves via Guix-patches via
2023-04-07 16:14 ` [bug#62202] [PATCH 0/21] Juliahub import script Simon Tournier
2023-04-08 22:07 ` Ludovic Courtès
2023-08-08 15:24   ` Ludovic Courtès
2023-08-16 15:43     ` Simon Tournier
2023-09-15  9:45       ` Giovanni Biscuolo
2023-09-15 13:32         ` Nicolas Graves via Guix-patches via
2023-09-15 14:01           ` Simon Tournier
2023-09-18  9:31             ` Nicolas Graves via Guix-patches via
2023-09-18 18:06               ` Simon Tournier
2023-09-19  6:23                 ` Giovanni Biscuolo
2023-09-19  6:37                   ` Simon Tournier
2023-09-19  6:51                 ` Nicolas Graves via Guix-patches via
2023-10-02  9:34                   ` Simon Tournier
2023-12-19 18:28                     ` Nicolas Graves via Guix-patches via
2023-09-18 18:03 ` [bug#62202] [PATCH v2 01/23] DRAFT guix: import: go: Add optional transform-version to vcs->origin Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 02/23] DRAFT TODO guix: import: utils: Add git->origin+dir Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 03/23] DRAFT TODO: guix: import: utils: Fix corner cases beautify-descritption Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 04/23] DRAFT import: Add julia Simon Tournier
2023-09-18 18:03   ` [bug#66088] [PATCH v2 05/23] DRAFT import: juliahub: Add support for native-inputs Simon Tournier
2023-09-18 18:03   ` [bug#66077] [PATCH v2 06/23] DRAFT import: juliahub: Correct source parsing Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 07/23] DRAFT import: juliahub: Add indirect dependencies Simon Tournier
2023-09-18 18:03   ` [bug#66090] [PATCH v2 08/23] DRAFT import: juliahub: Add updater and recursive-importer Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 09/23] DRAFT import: juliahub: Filter out julia stdlibs Simon Tournier
2023-09-18 18:03     ` [bug#66087] " Simon Tournier
2023-09-18 18:03   ` [bug#66076] [PATCH v2 10/23] DRAFT import: juliahub: Simplify juliahub dependency management Simon Tournier
2023-09-18 18:03   ` [bug#66092] [PATCH v2 11/23] DRAFT import: juliahub: Improve " Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 12/23] DRAFT import: juliahub: Add functions to parse the git repo for a git tag Simon Tournier
2023-09-18 18:03   ` [bug#66089] [PATCH v2 13/23] DRAFT import: juliahub: Improve test dependencies parsing Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 14/23] DRAFT import: juliahub: Handle the case where we have a subdirectory Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 15/23] DRAFT import: juliahub: Add support for versions for juliahub-fetch Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 16/23] DRAFT import: juliahub: Filter out stdlibs from test-dependencies Simon Tournier
2023-09-18 18:03   ` [bug#66086] [PATCH v2 17/23] DRAFT import: juliahub: More robust toml regex parser Simon Tournier
2023-09-18 18:03   ` [bug#66079] [PATCH v2 18/23] DRAFT import: juliahub: Beautify description Simon Tournier
2023-09-18 18:03   ` [bug#66080] [PATCH v2 19/23] DRAFT import: juliahub: Fix license management Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 20/23] DRAFT import: juliahub: Fix version management Simon Tournier
2023-09-18 18:03   ` [bug#66085] [PATCH v2 21/23] DRAFT import: juliahub: Fix undefined homepages Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 22/23] DRAFT import: juliahub: output package names as symbols Simon Tournier
2023-09-18 18:03   ` [bug#62202] [PATCH v2 23/23] DRAFT guix: import: julia: Fix beautify Simon Tournier
2023-12-21 14:01 ` [bug#62202] [PATCH v3 1/4] import: utils: Add function git->origin Nicolas Graves via Guix-patches via
2023-12-21 14:01   ` [bug#62202] [PATCH v3 2/4] import: Add juliahub importer Nicolas Graves via Guix-patches via
2023-12-21 14:01   ` [bug#62202] [PATCH v3 3/4] import: juliahub: Beautify description Nicolas Graves via Guix-patches via
2023-12-21 14:01   ` [bug#62202] [PATCH v3 4/4] import: utils: Rule out texinfo common syntax from @ escape Nicolas Graves via Guix-patches via
2024-02-03 23:07 ` [bug#62202] [PATCH v4 1/6] import: utils: Add function git->origin Nicolas Graves via Guix-patches via
2024-02-03 23:07   ` [bug#62202] [PATCH v4 2/6] import: Add juliahub importer Nicolas Graves via Guix-patches via
2024-02-03 23:07   ` [bug#62202] [PATCH v4 3/6] import: juliahub: Beautify description Nicolas Graves via Guix-patches via
2024-02-03 23:07   ` [bug#62202] [PATCH v4 4/6] import: utils: Rule out texinfo common syntax from @ escape Nicolas Graves via Guix-patches via
2024-02-03 23:07   ` [bug#62202] [PATCH v4 5/6] tests: go: Add mock-git->origin function Nicolas Graves via Guix-patches via
2024-02-03 23:07   ` Nicolas Graves via Guix-patches via [this message]
2024-04-01 20:50     ` [bug#62202] [PATCH v4 6/6] tests: juliahub: Add unit tests for (guix import juliahub) Ludovic Courtès
2024-04-02 11:52       ` Nicolas Graves via Guix-patches via
2024-04-09  7:29       ` Nicolas Graves via Guix-patches via
2024-04-11 10:56         ` Nicolas Graves via Guix-patches via
2024-04-16 16:52           ` Ludovic Courtès
2024-04-16 19:11             ` Nicolas Graves via Guix-patches via
2024-04-17  8:51               ` Ludovic Courtès
2024-04-21 16:08                 ` Nicolas Graves via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240203230807.25751-6-ngraves@ngraves.fr \
    --to=guix-patches@gnu.org \
    --cc=62202@debbugs.gnu.org \
    --cc=ngraves@ngraves.fr \
    --cc=zimoun.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.