2019-05-15 08:05:14 +01:00
|
|
|
(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"
|
2019-08-04 09:39:40 +01:00
|
|
|
#f)
|
2019-05-15 08:05:14 +01:00
|
|
|
("License 2"
|
|
|
|
|
"https://gnu.org/licenses/test-2.html"
|
2019-08-04 09:39:40 +01:00
|
|
|
#f)
|
|
|
|
|
("License 3"
|
|
|
|
|
#f
|
|
|
|
|
#f)))))
|
2019-05-15 08:05:14 +01:00
|
|
|
|
|
|
|
|
(with-postgresql-connection
|
2019-07-12 19:45:41 +01:00
|
|
|
"test-model-license"
|
2019-05-15 08:05:14 +01:00
|
|
|
(lambda (conn)
|
2020-02-24 21:16:41 +00:00
|
|
|
(check-test-database! conn)
|
|
|
|
|
|
2019-05-15 08:05:14 +01:00
|
|
|
(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)
|