1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (test-gem)
22 #:use-module (guix import gem)
23 #:use-module (guix base32)
24 #:use-module (gcrypt hash)
25 #:use-module (guix tests)
26 #:use-module ((guix build utils) #:select (delete-file-recursively))
27 #:use-module (srfi srfi-41)
28 #:use-module (srfi srfi-64)
29 #:use-module (ice-9 match))
34 \"version\": \"1.0.0\",
35 \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\",
36 \"info\": \"A cool gem\",
37 \"homepage_uri\": \"https://example.com\",
40 { \"name\": \"bundler\" },
44 \"licenses\": [\"MIT\", \"Apache 2.0\"]
50 \"version\": \"1.0.0\",
51 \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\",
52 \"info\": \"Another cool gem\",
53 \"homepage_uri\": \"https://example.com\",
56 { \"name\": \"bundler\" },
59 \"licenses\": [\"MIT\", \"Apache 2.0\"]
62 (define test-bundler-json
64 \"name\": \"bundler\",
65 \"version\": \"1.14.2\",
66 \"sha\": \"3bb53e03db0a8008161eb4c816ccd317120d3c415ba6fee6f90bbc7f7eec8690\",
67 \"info\": \"Ruby gem bundler\",
68 \"homepage_uri\": \"https://bundler.io/\",
72 \"licenses\": [\"MIT\"]
77 (test-assert "gem->guix-package"
78 ;; Replace network resources with sample data.
79 (mock ((guix http-client) http-fetch
82 ("https://rubygems.org/api/v1/gems/foo.json"
83 (values (open-input-string test-foo-json)
84 (string-length test-foo-json)))
85 (_ (error "Unexpected URL: " url)))))
86 (match (gem->guix-package "foo")
92 ('uri ('rubygems-uri "foo" 'version))
95 "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
96 ('build-system 'ruby-build-system)
99 (("bundler" ('unquote 'bundler))
100 ("ruby-bar" ('unquote 'ruby-bar)))))
101 ('synopsis "A cool gem")
102 ('description "This package provides a cool gem")
103 ('home-page "https://example.com")
104 ('license ('list 'license:expat 'license:asl2.0)))
109 (test-assert "gem-recursive-import"
110 ;; Replace network resources with sample data.
111 (mock ((guix http-client) http-fetch
114 ("https://rubygems.org/api/v1/gems/foo.json"
115 (values (open-input-string test-foo-json)
116 (string-length test-foo-json)))
117 ("https://rubygems.org/api/v1/gems/bar.json"
118 (values (open-input-string test-bar-json)
119 (string-length test-bar-json)))
120 ("https://rubygems.org/api/v1/gems/bundler.json"
121 (values (open-input-string test-bundler-json)
122 (string-length test-bundler-json)))
123 (_ (error "Unexpected URL: " url)))))
124 (match (stream->list (gem-recursive-import "foo"))
131 ('uri ('rubygems-uri "foo" 'version))
134 "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
135 ('build-system 'ruby-build-system)
138 (("bundler" ('unquote 'bundler))
139 ("ruby-bar" ('unquote 'ruby-bar)))))
140 ('synopsis "A cool gem")
141 ('description "This package provides a cool gem")
142 ('home-page "https://example.com")
143 ('license ('list 'license:expat 'license:asl2.0)))
145 ('name "ruby-bundler")
150 ('uri ('rubygems-uri "bundler" 'version))
153 "1446xiz7zg0bz7kgx9jv84y0s4hpsg61dj5l3qb0i00avc1kxd9v"))))
154 ('build-system 'ruby-build-system)
155 ('synopsis "Ruby gem bundler")
156 ('description "Ruby gem bundler")
157 ('home-page "https://bundler.io/")
158 ('license 'license:expat))
165 ('uri ('rubygems-uri "bar" 'version))
168 "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
169 ('build-system 'ruby-build-system)
172 (('"bundler" ('unquote 'bundler)))))
173 ('synopsis "Another cool gem")
174 ('description "Another cool gem")
175 ('home-page "https://example.com")
176 ('license ('list 'license:expat 'license:asl2.0))))