mirror of
git://git.savannah.gnu.org/guix/data-service.git
synced 2023-12-14 03:23:03 +01:00
The licenses table, along with the package_metadata table had duplicate values. This could happen as the unique constraints on those tables didn't properly account for the nullable fields. The duplicates in those tables also affected the license_sets, packages, package_derivations tables in a similar way. Finally, the guix_revision_package_derivations table was also affected. This commit adds a migration to fix the data, as well as the constraints. THe code to populate the licenses and package_metadata tables is also updated.
46 lines
1.2 KiB
Scheme
46 lines
1.2 KiB
Scheme
(define-module (tests model-license-set)
|
|
#: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-set))
|
|
|
|
(use-modules (tests driver))
|
|
|
|
(test-begin "test-model-license-set")
|
|
|
|
(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"
|
|
#f)
|
|
("License 2"
|
|
#f
|
|
#f)))))
|
|
|
|
(with-postgresql-connection
|
|
"test-model-license-set"
|
|
(lambda (conn)
|
|
(with-postgresql-transaction
|
|
conn
|
|
(lambda (conn)
|
|
(test-assert "works"
|
|
(inferior-packages->license-set-ids conn #f #f)))
|
|
#:always-rollback? #t)
|
|
|
|
(with-postgresql-transaction
|
|
conn
|
|
(lambda (conn)
|
|
(test-equal "works repeatedly"
|
|
(inferior-packages->license-set-ids conn #f #f)
|
|
(inferior-packages->license-set-ids conn #f #f)))
|
|
#:always-rollback? #t))))
|
|
|
|
(test-end)
|