2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/data-service.git synced 2023-12-14 03:23:03 +01:00
data-service/tests/model-license.scm
Christopher Baines 2f41fe79be Adapt some license related code to work without mock in the tests
With Guile 3, there's a potential for mock to work in even fewer
circumstances. So, adapt the code to enable writing the tests without mock.
2020-02-24 21:47:34 +00:00

45 lines
1.1 KiB
Scheme

(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")
(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))))
(with-postgresql-connection
"test-model-license"
(lambda (conn)
(check-test-database! conn)
(with-postgresql-transaction
conn
(lambda (conn)
(test-assert "works"
(inferior-packages->license-id-lists conn license-data)))
#:always-rollback? #t)
(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)))
(test-end)