| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 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 | |
| 31 | (%graft? #f)
|
| 32 |
|
| 33 | (define test-json
|
| 34 | "{
|
| 35 | \"packages\": {
|
| 36 | \"foo/bar\": [
|
| 37 | {
|
| 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 | |
| 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")
|