aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-05-15 08:05:14 +0100
committerChristopher Baines <mail@cbaines.net>2019-05-15 08:05:14 +0100
commit16799a34a96bfa240b3eb47d75c935afab8c51a1 (patch)
treedb03a3f86bfaa69f5522e31504de1bd64576d6e8 /tests
parent28c2d4608149b55d7547eab563e688814f3d7254 (diff)
downloaddata-service-16799a34a96bfa240b3eb47d75c935afab8c51a1.tar
data-service-16799a34a96bfa240b3eb47d75c935afab8c51a1.tar.gz
Store license information for packages
And display this on the package page. This uses a couple of new tables, and an additional field in the package_metadata table. Currently, the order of the licenses in the package definition isn't stored, as I'm not sure the order in the list is significant.
Diffstat (limited to 'tests')
-rw-r--r--tests/model-license-set.scm44
-rw-r--r--tests/model-license.scm42
2 files changed, 86 insertions, 0 deletions
diff --git a/tests/model-license-set.scm b/tests/model-license-set.scm
new file mode 100644
index 0000000..fecf242
--- /dev/null
+++ b/tests/model-license-set.scm
@@ -0,0 +1,44 @@
+ (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"
+ "https://example.com/why-license-1")
+ ("License 2"
+ "https://gnu.org/licenses/test-2.html"
+ "https://example.com/why-license-2")))))
+
+ (with-postgresql-connection
+ (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)
diff --git a/tests/model-license.scm b/tests/model-license.scm
new file mode 100644
index 0000000..cdec491
--- /dev/null
+++ b/tests/model-license.scm
@@ -0,0 +1,42 @@
+(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 (tests mock-inferior)
+ #:use-module (guix-data-service model license))
+
+(test-begin "test-model-license")
+
+(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"
+ "https://example.com/why-license-1")
+ ("License 2"
+ "https://gnu.org/licenses/test-2.html"
+ "https://example.com/why-license-2")))))
+
+ (with-postgresql-connection
+ (lambda (conn)
+ (with-postgresql-transaction
+ conn
+ (lambda (conn)
+ (test-assert "works"
+ (inferior-packages->license-id-lists conn #f #f)))
+ #:always-rollback? #t)
+
+ (with-postgresql-transaction
+ conn
+ (lambda (conn)
+ (test-equal "works repeatedly"
+ (inferior-packages->license-id-lists conn #f #f)
+ (inferior-packages->license-id-lists conn #f #f)))
+ #:always-rollback? #t))))
+
+(test-end)