guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#62202] [PATCH v4 6/6] tests: juliahub: Add unit tests for (guix imp


From: Ludovic Courtès
Subject: [bug#62202] [PATCH v4 6/6] tests: juliahub: Add unit tests for (guix import juliahub).
Date: Mon, 01 Apr 2024 22:50:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi,

As part of this v4, I would recommend merging patches 2, 3, and 6, such
that there’s a single self-contained patch adding ‘guix import
juliahub’.  (That’s what we usually do and I find it clearer because we
immediately see what goes together.)

Nicolas Graves <ngraves@ngraves.fr> skribis:

> * tests/juliahub.scm : Add unit tests juliahub-redirect,
> julia-general-registry-parsing, juliahub-fetch.

Just “New file.”

Some of the other files lack a commit log; we can add it for you, but
it’d be great if you could do it upfront.

> ---
>  tests/juliahub.scm | 185 +++++++++++++++++++++++++++++++++++++++++++++

Please add it to ‘Makefile.am’.

[...]

> +(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)

I strongly encourage using ‘with-http-server’ using the same strategy
that’s used in ‘tests/pypi.scm’ and others instead of mocking.  (‘mock’
is very sensitive to inlining, plus you sorta have to make assumptions
about the code path to be able to mock the right things.)

> +(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"))))))

Checking for ‘juliahub-package?’ doesn’t tell us much; what about
checking the whole package, similar to what is done in other importer
tests?

Thanks,
Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]