2019-08-31 12:11:58 +01:00
|
|
|
(define-module (tests model-lint-checker)
|
|
|
|
|
#:use-module (srfi srfi-64)
|
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:use-module (guix-data-service database)
|
|
|
|
|
#:use-module (guix-data-service model lint-checker))
|
|
|
|
|
|
|
|
|
|
(test-begin "test-model-lint-checker")
|
|
|
|
|
|
|
|
|
|
(define data
|
|
|
|
|
'((name-1 "description-1" #t)
|
|
|
|
|
(name-2 "description-2" #f)))
|
|
|
|
|
|
|
|
|
|
(with-postgresql-connection
|
|
|
|
|
"test-model-lint-checker"
|
|
|
|
|
(lambda (conn)
|
2020-02-24 21:16:41 +00:00
|
|
|
(check-test-database! conn)
|
|
|
|
|
|
2019-08-31 12:11:58 +01:00
|
|
|
(test-assert "single insert"
|
|
|
|
|
(with-postgresql-transaction
|
|
|
|
|
conn
|
|
|
|
|
(lambda (conn)
|
|
|
|
|
(match (lint-checkers->lint-checker-ids conn data)
|
2019-09-04 19:24:22 +02:00
|
|
|
(((? number? id1) (? number? id2))
|
2019-08-31 12:11:58 +01:00
|
|
|
#t)))
|
|
|
|
|
#:always-rollback? #t))
|
|
|
|
|
|
|
|
|
|
(test-assert "double insert"
|
|
|
|
|
(with-postgresql-transaction
|
|
|
|
|
conn
|
|
|
|
|
(lambda (conn)
|
|
|
|
|
(match (lint-checkers->lint-checker-ids conn data)
|
2019-09-04 19:24:22 +02:00
|
|
|
(((? number? id1) (? number? id2))
|
2019-08-31 12:11:58 +01:00
|
|
|
(match (lint-checkers->lint-checker-ids conn data)
|
2019-09-04 19:24:22 +02:00
|
|
|
(((? number? second-id1) (? number? second-id2))
|
|
|
|
|
(and (eq? id1 second-id1)
|
|
|
|
|
(eq? id2 second-id2)))))))
|
2019-08-31 12:11:58 +01:00
|
|
|
#:always-rollback? #t))))
|
|
|
|
|
|
|
|
|
|
(test-end)
|