2019-05-05 14:35:48 +02:00
|
|
|
(define-module (test-model-git-repository)
|
2019-09-04 19:24:22 +02:00
|
|
|
#:use-module (ice-9 match)
|
2019-05-05 14:35:48 +02:00
|
|
|
#:use-module (srfi srfi-64)
|
|
|
|
#:use-module (guix-data-service database)
|
|
|
|
#:use-module (guix-data-service model git-repository))
|
|
|
|
|
|
|
|
(test-begin "test-model-git-repository")
|
|
|
|
|
|
|
|
(with-postgresql-connection
|
2019-07-12 20:45:41 +02:00
|
|
|
"test-model-git-repository"
|
2019-05-05 14:35:48 +02:00
|
|
|
(lambda (conn)
|
2020-02-24 22:16:41 +01:00
|
|
|
(check-test-database! conn)
|
|
|
|
|
2019-05-05 14:35:48 +02:00
|
|
|
(test-assert "returns an id for a non existent URL"
|
|
|
|
(with-postgresql-transaction
|
|
|
|
conn
|
|
|
|
(lambda (conn)
|
2019-09-04 19:24:22 +02:00
|
|
|
(match (git-repository-url->git-repository-id
|
|
|
|
conn
|
|
|
|
"test-non-existent-url")
|
|
|
|
((? number? x)
|
|
|
|
#t)))
|
2019-05-05 14:35:48 +02:00
|
|
|
#:always-rollback? #t))
|
|
|
|
|
2019-09-04 19:24:22 +02:00
|
|
|
(let* ((url "test-url")
|
|
|
|
(id (git-repository-url->git-repository-id conn url)))
|
2019-05-05 14:35:48 +02:00
|
|
|
(with-postgresql-transaction
|
|
|
|
conn
|
|
|
|
(lambda (conn)
|
2019-09-04 19:24:22 +02:00
|
|
|
(test-equal "returns the right id for an existing URL"
|
|
|
|
id
|
|
|
|
(git-repository-url->git-repository-id conn url)))
|
2019-05-05 14:35:48 +02:00
|
|
|
#:always-rollback? #t))))
|
|
|
|
|
|
|
|
(test-end)
|