From 0ea939fb796fdd4f0d46d3534b2ec6135e0f3dc7 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 13 Jan 2019 15:36:49 +0100 Subject: guix package: '--list-available' can use data from the cache. * gnu/packages.scm (fold-available-packages): New procedure. * guix/scripts/package.scm (process-query): Use it instead of 'fold-packages'. * tests/packages.scm ("fold-available-packages with/without cache"): New test. --- tests/packages.scm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/packages.scm b/tests/packages.scm index 8aa117a2e7..ed635d9011 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -995,6 +995,28 @@ ((one) (eq? one guile-2.0)))) +(test-assert "fold-available-packages with/without cache" + (let () + (define no-cache + (fold-available-packages (lambda* (name version result #:rest rest) + (cons (cons* name version rest) + result)) + '())) + + (define from-cache + (call-with-temporary-directory + (lambda (cache) + (generate-package-cache cache) + (mock ((guix describe) current-profile (const cache)) + (mock ((gnu packages) cache-is-authoritative? (const #t)) + (fold-available-packages (lambda* (name version result + #:rest rest) + (cons (cons* name version rest) + result)) + '())))))) + + (lset= equal? no-cache from-cache))) + (test-assert "find-packages-by-name" (match (find-packages-by-name "hello") (((? (cut eq? hello <>))) #t) -- cgit v1.2.3