2019-05-15 09:05:14 +02: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 (guix-data-service model license))
|
|
|
|
|
|
|
|
(test-begin "test-model-license")
|
|
|
|
|
2020-02-24 22:35:44 +01:00
|
|
|
(define license-data
|
|
|
|
'((("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))))
|
2019-05-15 09:05:14 +02:00
|
|
|
|
2020-02-24 22:35:44 +01:00
|
|
|
(with-postgresql-connection
|
|
|
|
"test-model-license"
|
|
|
|
(lambda (conn)
|
|
|
|
(check-test-database! conn)
|
2020-02-24 22:16:41 +01:00
|
|
|
|
2020-02-24 22:35:44 +01:00
|
|
|
(with-postgresql-transaction
|
|
|
|
conn
|
|
|
|
(lambda (conn)
|
|
|
|
(test-assert "works"
|
|
|
|
(inferior-packages->license-id-lists conn license-data)))
|
|
|
|
#:always-rollback? #t)
|
2019-05-15 09:05:14 +02:00
|
|
|
|
2020-02-24 22:35:44 +01:00
|
|
|
(with-postgresql-transaction
|
|
|
|
conn
|
|
|
|
(lambda (conn)
|
|
|
|
(test-equal "works repeatedly"
|
|
|
|
(inferior-packages->license-id-lists conn license-data)
|
|
|
|
(inferior-packages->license-id-lists conn license-data)))
|
|
|
|
#:always-rollback? #t)))
|
2019-05-15 09:05:14 +02:00
|
|
|
|
|
|
|
(test-end)
|