summaryrefslogtreecommitdiff
path: root/tests/import/composer.scm
diff options
context:
space:
mode:
authorNicolas Graves <ngraves@ngraves.fr>2025-09-17 01:28:59 +0200
committerLudovic Courtès <ludo@gnu.org>2025-10-01 11:04:17 +0200
commita14df090978e91779e7e072a03002aebf2db7d98 (patch)
treea3be710feffbdbe0e322aa39986a495e59713743 /tests/import/composer.scm
parenta34376aa7189447f0850fb825ca20a198557f9ce (diff)
import: composer: Move tests to tests/import/composer.scm.
* tests/composer.scm: Move to tests/import/composer.scm. * Makefile.am: Refresh it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/import/composer.scm')
-rw-r--r--tests/import/composer.scm88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/import/composer.scm b/tests/import/composer.scm
new file mode 100644
index 00000000000..9114fef19ed
--- /dev/null
+++ b/tests/import/composer.scm
@@ -0,0 +1,88 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
3;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr>
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (test-composer)
21 #:use-module (guix import composer)
22 #:use-module (guix base32)
23 #:use-module (gcrypt hash)
24 #:use-module (guix tests http)
25 #:use-module (guix grafts)
26 #:use-module (srfi srfi-64)
27 #:use-module (web client)
28 #:use-module (ice-9 match))
29
30;; Globally disable grafts because they can trigger early builds.
31(%graft? #f)
32
33(define test-json
34 "{
35 \"packages\": {
36 \"foo/bar\": {
37 \"0.1\": {
38 \"name\": \"foo/bar\",
39 \"description\": \"description\",
40 \"keywords\": [\"testing\"],
41 \"homepage\": \"http://example.com\",
42 \"version\": \"0.1\",
43 \"license\": [\"BSD-3-Clause\"],
44 \"source\": {
45 \"type\": \"url\",
46 \"url\": \"http://example.com/Bar-0.1.tar.gz\"
47 },
48 \"require\": {},
49 \"require-dev\": {\"phpunit/phpunit\": \"1.0.0\"}
50 }
51 }
52 }
53}")
54
55(define test-source
56 "foobar")
57
58(test-begin "composer")
59
60(test-assert "composer->guix-package"
61 ;; Replace network resources with sample data.
62 (with-http-server `((200 ,test-json)
63 (200 ,test-source))
64 (parameterize ((%composer-base-url (%local-url))
65 (current-http-proxy (%local-url)))
66 (match (composer->guix-package "foo/bar")
67 (`(package
68 (name "php-foo-bar")
69 (version "0.1")
70 (source (origin
71 (method url-fetch)
72 (uri "http://example.com/Bar-0.1.tar.gz")
73 (sha256
74 (base32
75 ,(? string? hash)))))
76 (build-system composer-build-system)
77 (native-inputs (list php-phpunit-phpunit))
78 (synopsis "")
79 (description "description")
80 (home-page "http://example.com")
81 (license license:bsd-3))
82 (string=? (bytevector->nix-base32-string
83 (call-with-input-string test-source port-sha256))
84 hash))
85 (x
86 (pk 'fail x #f))))))
87
88(test-end "composer")