aboutsummaryrefslogtreecommitdiff
path: root/tests/model-package-metadata.scm
blob: 5c0092d0bdf7a33903825edb77e8ffb68ee71482 (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
47
48
49
50
51
(define-module (test-model-package-metadata)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-64)
  #:use-module (guix utils)
  #:use-module (tests mock-inferior)
  #:use-module (guix-data-service database))

(test-begin "test-model-package-metadata")

(define mock-inferior-package-foo
  (mock-inferior-package
   (name "foo")
   (version "2")
   (synopsis "Foo")
   (description "Foo description")
   (home-page "https://example.com")
   (location (location "file.scm" 5 0))))

(with-mock-inferior-packages
 (lambda ()
   (use-modules (guix-data-service model package)
                (guix-data-service model git-repository)
                (guix-data-service model guix-revision)
                (guix-data-service model package-metadata))

   (with-postgresql-connection
    (lambda (conn)
      (test-assert "inferior-packages->package-metadata-ids"
        (with-postgresql-transaction
         conn
         (lambda (conn)
           (match
               (inferior-packages->package-metadata-ids
                conn
                (list mock-inferior-package-foo))
             ((x) (string? x))))
         #:always-rollback? #t))

      (with-postgresql-transaction
       conn
       (lambda (conn)
         (test-equal "inferior-packages->package-metadata-ids"
           (inferior-packages->package-metadata-ids
            conn
            (list mock-inferior-package-foo))
           (inferior-packages->package-metadata-ids
            conn
            (list mock-inferior-package-foo)))
         #:always-rollback? #t))))))

(test-end)