diff options
author | Danjela Lura <danielaluraa@gmail.com> | 2020-06-19 14:15:38 +0200 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-06-19 16:03:32 +0100 |
commit | 365bf27838d3997c97ab2c4a77905a5e3b20d867 (patch) | |
tree | b000b6a4e61eaf08eb673e358340403c0b655c41 | |
parent | a3ac33c0e1463239fe9612d7798fd3419ac3c7bc (diff) | |
download | data-service-365bf27838d3997c97ab2c4a77905a5e3b20d867.tar data-service-365bf27838d3997c97ab2c4a77905a5e3b20d867.tar.gz |
Fix the test-model-package test
Signed-off-by: Christopher Baines <mail@cbaines.net>
-rw-r--r-- | guix-data-service/model/package-metadata.scm | 12 | ||||
-rw-r--r-- | tests/model-package.scm | 10 |
2 files changed, 17 insertions, 5 deletions
diff --git a/guix-data-service/model/package-metadata.scm b/guix-data-service/model/package-metadata.scm index e753dea..f2319fc 100644 --- a/guix-data-service/model/package-metadata.scm +++ b/guix-data-service/model/package-metadata.scm @@ -27,10 +27,12 @@ #:use-module (guix packages) #:use-module (guix i18n) #:use-module (guix inferior) + #:use-module (guix-data-service utils) #:use-module (guix-data-service model location) #:use-module (guix-data-service model utils) #:export (select-package-metadata-by-revision-name-and-version inferior-packages->package-metadata-ids + inferior-packages->translated-package-descriptions-and-synopsis package-description-and-synopsis-locale-options-guix-revision)) @@ -203,9 +205,9 @@ WHERE packages.id IN ( ";")) (define (inferior-packages->translated-package-descriptions-and-synopsis inferior - inferior-package-id) + inferior-package) - (define (translate inferior-package) + (define (translate inferior-package-id) `(let* ((package (hashv-ref %package-table ,inferior-package-id)) (source-locale "en_US.utf8") (source-synopsis @@ -260,7 +262,9 @@ WHERE packages.id IN ( (cons (cons source-locale source-synopsis) synopsis-by-locale)))) - (inferior-eval (translate inferior-package-id) inferior)) + (inferior-eval (translate (inferior-package-id inferior-package)) inferior)) + +(prevent-inlining-for-tests inferior-packages->translated-package-descriptions-and-synopsis) (define (package-synopsis-data->package-synopsis-ids conn synopsis-by-locale) @@ -366,7 +370,7 @@ WHERE packages.id IN ( (map (lambda (package license-set-id) (let ((translated-package-descriptions-and-synopsis (inferior-packages->translated-package-descriptions-and-synopsis - inferior (inferior-package-id package)))) + inferior package))) (list (non-empty-string-or-false (inferior-package-home-page package)) (location->location-id diff --git a/tests/model-package.scm b/tests/model-package.scm index 0f2c796..3999230 100644 --- a/tests/model-package.scm +++ b/tests/model-package.scm @@ -45,6 +45,12 @@ (list mock-inferior-package-foo mock-inferior-package-foo-2)) +(mock + ((guix-data-service model package-metadata) + inferior-packages->translated-package-descriptions-and-synopsis + (lambda (inferior inferior-package) + (cons `(("en_US.utf8" . "Fake synopsis")) + `(("en_US.utf8" . "Fake description"))))) (with-mock-inferior-packages (lambda () (use-modules (guix-data-service model package) @@ -63,6 +69,7 @@ (test-assert "inferior-packages->package-ids works once" (let ((package-metadata-ids (inferior-packages->package-metadata-ids conn + "" mock-inferior-packages (test-license-set-ids conn)))) (match (inferior-packages->package-ids @@ -78,6 +85,7 @@ (lambda (conn) (let ((package-metadata-ids (inferior-packages->package-metadata-ids conn + "" mock-inferior-packages (test-license-set-ids conn)))) (test-equal @@ -91,6 +99,6 @@ (zip (map mock-inferior-package-name mock-inferior-packages) (map mock-inferior-package-version mock-inferior-packages) package-metadata-ids))))) - #:always-rollback? #t))))) + #:always-rollback? #t)))))) (test-end) |