[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
54/155: tests: Mock up http-fetch in import tests.
From: |
John Darrington |
Subject: |
54/155: tests: Mock up http-fetch in import tests. |
Date: |
Wed, 21 Dec 2016 20:48:33 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit 75f265cd531583d7bcd2cad6cc9c932d4542a1b8
Author: Ricardo Wurmus <address@hidden>
Date: Sun Dec 18 09:55:17 2016 +0100
tests: Mock up http-fetch in import tests.
This is a follow-up to commit 63773200d7ac68fcaee6efd9ffe8ea7aa3fafa38.
* tests/gem.scm ("gem->guix-package"): Replace mock definition of
"url-fetch" with "http-fetch".
* tests/pypi.scm ("pypi->guix-package"): Add mock definition of
"http-fetch".
---
tests/gem.scm | 10 +++---
tests/pypi.scm | 95 +++++++++++++++++++++++++++++---------------------------
2 files changed, 55 insertions(+), 50 deletions(-)
diff --git a/tests/gem.scm b/tests/gem.scm
index a46c2b1..669cd8e 100644
--- a/tests/gem.scm
+++ b/tests/gem.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 David Thompson <address@hidden>
+;;; Copyright © 2016 Ricardo Wurmus <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -45,13 +46,12 @@
(test-assert "gem->guix-package"
;; Replace network resources with sample data.
- (mock ((guix import utils) url-fetch
- (lambda (url file-name)
+ (mock ((guix http-client) http-fetch
+ (lambda (url)
(match url
("https://rubygems.org/api/v1/gems/foo.json"
- (with-output-to-file file-name
- (lambda ()
- (display test-json))))
+ (values (open-input-string test-json)
+ (string-length test-json)))
(_ (error "Unexpected URL: " url)))))
(match (gem->guix-package "foo")
(('package
diff --git a/tests/pypi.scm b/tests/pypi.scm
index 9d2fcc7..1f7ac25 100644
--- a/tests/pypi.scm
+++ b/tests/pypi.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 David Thompson <address@hidden>
+;;; Copyright © 2016 Ricardo Wurmus <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -91,51 +92,55 @@ baz > 13.37")
(test-assert "pypi->guix-package"
;; Replace network resources with sample data.
- (mock ((guix import utils) url-fetch
- (lambda (url file-name)
- (match url
- ("https://pypi.python.org/pypi/foo/json"
- (with-output-to-file file-name
- (lambda ()
- (display test-json))))
- ("https://example.com/foo-1.0.0.tar.gz"
- (begin
- (mkdir "foo-1.0.0")
- (with-output-to-file "foo-1.0.0/requirements.txt"
- (lambda ()
- (display test-requirements)))
- (system* "tar" "czvf" file-name "foo-1.0.0/")
- (delete-file-recursively "foo-1.0.0")
- (set! test-source-hash
- (call-with-input-file file-name port-sha256))))
- ("https://example.com/foo-1.0.0-py2.py3-none-any.whl" #f)
- (_ (error "Unexpected URL: " url)))))
- (match (pypi->guix-package "foo")
- (('package
- ('name "python-foo")
- ('version "1.0.0")
- ('source ('origin
- ('method 'url-fetch)
- ('uri (string-append "https://example.com/foo-"
- version ".tar.gz"))
- ('sha256
- ('base32
- (? string? hash)))))
- ('build-system 'python-build-system)
- ('propagated-inputs
- ('quasiquote
- (("python-bar" ('unquote 'python-bar))
- ("python-baz" ('unquote 'python-baz))
- ("python-setuptools" ('unquote 'python-setuptools)))))
- ('home-page "http://example.com")
- ('synopsis "summary")
- ('description "summary")
- ('license 'license:lgpl2.0))
- (string=? (bytevector->nix-base32-string
- test-source-hash)
- hash))
- (x
- (pk 'fail x #f)))))
+ (mock ((guix import utils) url-fetch
+ (lambda (url file-name)
+ (match url
+ ("https://example.com/foo-1.0.0.tar.gz"
+ (begin
+ (mkdir "foo-1.0.0")
+ (with-output-to-file "foo-1.0.0/requirements.txt"
+ (lambda ()
+ (display test-requirements)))
+ (system* "tar" "czvf" file-name "foo-1.0.0/")
+ (delete-file-recursively "foo-1.0.0")
+ (set! test-source-hash
+ (call-with-input-file file-name port-sha256))))
+ ("https://example.com/foo-1.0.0-py2.py3-none-any.whl" #f)
+ (_ (error "Unexpected URL: " url)))))
+ (mock ((guix http-client) http-fetch
+ (lambda (url)
+ (match url
+ ("https://pypi.python.org/pypi/foo/json"
+ (values (open-input-string test-json)
+ (string-length test-json)))
+ ("https://example.com/foo-1.0.0-py2.py3-none-any.whl" #f)
+ (_ (error "Unexpected URL: " url)))))
+ (match (pypi->guix-package "foo")
+ (('package
+ ('name "python-foo")
+ ('version "1.0.0")
+ ('source ('origin
+ ('method 'url-fetch)
+ ('uri (string-append "https://example.com/foo-"
+ version ".tar.gz"))
+ ('sha256
+ ('base32
+ (? string? hash)))))
+ ('build-system 'python-build-system)
+ ('propagated-inputs
+ ('quasiquote
+ (("python-bar" ('unquote 'python-bar))
+ ("python-baz" ('unquote 'python-baz))
+ ("python-setuptools" ('unquote 'python-setuptools)))))
+ ('home-page "http://example.com")
+ ('synopsis "summary")
+ ('description "summary")
+ ('license 'license:lgpl2.0))
+ (string=? (bytevector->nix-base32-string
+ test-source-hash)
+ hash))
+ (x
+ (pk 'fail x #f))))))
(test-skip (if (which "zip") 0 1))
(test-assert "pypi->guix-package, wheels"
- 93/155: gnu: linux-libre: Fix typo., (continued)
- 93/155: gnu: linux-libre: Fix typo., John Darrington, 2016/12/21
- 91/155: gnu: Add python-xopen., John Darrington, 2016/12/21
- 100/155: gnu: utox: Fix description., John Darrington, 2016/12/21
- 82/155: doc: Mention 'swapon'., John Darrington, 2016/12/21
- 70/155: gnu: wxmaxima: Update to 16.12.0., John Darrington, 2016/12/21
- 37/155: import cran: Remove more invalid characters from package names., John Darrington, 2016/12/21
- 38/155: import cran: Move guix-name to top-level., John Darrington, 2016/12/21
- 43/155: guix import: Print list of expressions., John Darrington, 2016/12/21
- 51/155: gnu: Add attribution line for Raoul Bonnal., John Darrington, 2016/12/21
- 60/155: tests: Adjust cpan tests., John Darrington, 2016/12/21
- 54/155: tests: Mock up http-fetch in import tests.,
John Darrington <=
- 58/155: build: check-final-inputs-self-contained has an exception for 'bash:include'., John Darrington, 2016/12/21
- 62/155: gnu: python-docutils: Update to 0.13.1, John Darrington, 2016/12/21
- 66/155: build: Add 'guix-publish.*.in' to the distribution., John Darrington, 2016/12/21
- 69/155: gnu: tor: split description into two parts for easier reading., John Darrington, 2016/12/21
- 72/155: gnu: gnumach-headers: Update to 1.8., John Darrington, 2016/12/21
- 75/155: gnu: pcsc-lite: Update to 1.8.19., John Darrington, 2016/12/21
- 87/155: gexp: Slightly simplify 'gexp-inputs'., John Darrington, 2016/12/21
- 84/155: doc: Mention 'grub' field of 'grub-configuration'., John Darrington, 2016/12/21
- 80/155: gnu: samba: Update to 4.5.3 [fixes CVE-2016-{2123, 2125, 2126}]., John Darrington, 2016/12/21
- 97/155: install: The list of services is now a plain list., John Darrington, 2016/12/21