aboutsummaryrefslogtreecommitdiff
path: root/tests/model-license.scm
blob: 8f4b0c398993ed3a3724e2187db5af8ec0e6e3eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(define-module (tests model-license)
  #:use-module (srfi srfi-64)
  #:use-module (guix utils)
  #:use-module (guix tests)
  #:use-module (guix-data-service database)
  #:use-module (tests mock-inferior)
  #:use-module (guix-data-service model license))

(test-begin "test-model-license")

(mock
 ((guix-data-service model license)
  inferior-packages->license-data
  (lambda (inf packages)
    '((("License 1"
        "https://gnu.org/licenses/test-1.html"
        "https://example.com/why-license-1"))
      (("License 1"
        "https://gnu.org/licenses/test-1.html"
        #f)
       ("License 2"
        "https://gnu.org/licenses/test-2.html"
        #f)
       ("License 3"
        #f
        #f)))))

 (with-postgresql-connection
  "test-model-license"
  (lambda (conn)
    (with-postgresql-transaction
     conn
     (lambda (conn)
       (test-assert "works"
         (inferior-packages->license-id-lists conn #f #f)))
     #:always-rollback? #t)

    (with-postgresql-transaction
     conn
     (lambda (conn)
       (test-equal "works repeatedly"
         (inferior-packages->license-id-lists conn #f #f)
         (inferior-packages->license-id-lists conn #f #f)))
     #:always-rollback? #t))))

(test-end)