aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-04-14 10:08:11 +0100
committerChristopher Baines <mail@cbaines.net>2019-04-14 10:08:11 +0100
commitef4fd5ab4fee64639dcd18ead2a82aa2235661fd (patch)
tree0715f16144a8eadd915d9d17efa4e273afd8ac75
parentd69f77d59eefc1ca577d6df0cfe6d8cd46742b82 (diff)
downloaddata-service-ef4fd5ab4fee64639dcd18ead2a82aa2235661fd.tar
data-service-ef4fd5ab4fee64639dcd18ead2a82aa2235661fd.tar.gz
Add an initial test
Along with the buildsystem changes to make `make check` work.
-rw-r--r--.gitignore4
-rw-r--r--Makefile.am13
-rw-r--r--configure.ac1
-rwxr-xr-xtest-env23
-rw-r--r--tests/model-derivation.scm18
5 files changed, 59 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 52dcad3..2054ba5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,10 @@ config.log
config.status
configure
+*.log
+tests/*.log
+tests/*.trs
+
guix-data-service/config.scm
scripts/guix-data-service
scripts/guix-data-service-process-jobs
diff --git a/Makefile.am b/Makefile.am
index ad9eddb..ca95abe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,3 +54,16 @@ SOURCES = \
guix-data-service/web/sxml.scm \
guix-data-service/web/util.scm \
guix-data-service/web/view/html.scm
+
+TEST_EXTENSIONS = .scm
+
+TESTS = \
+ tests/model-derivation.scm
+
+AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)"
+
+SCM_LOG_DRIVER = $(top_builddir)/test-env \
+ $(GUILE) --no-auto-compile -e main \
+ $(top_srcdir)/build-aux/test-driver.scm
+
+AM_SCM_LOG_DRIVER_FLAGS = --brief=yes
diff --git a/configure.ac b/configure.ac
index 138a31d..225e894 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,7 @@ AC_CONFIG_FILES([scripts/guix-data-service], [chmod +x scripts/guix-data-service
AC_CONFIG_FILES([scripts/guix-data-service-process-jobs], [chmod +x scripts/guix-data-service-process-jobs])
AC_CONFIG_FILES([scripts/guix-data-service-process-branch-updated-email], [chmod +x scripts/guix-data-service-process-branch-updated-email])
AC_CONFIG_FILES([scripts/guix-data-service-query-build-servers], [chmod +x scripts/guix-data-service-query-build-servers])
+AC_CONFIG_FILES([test-env:build-aux/test-env.in], [chmod +x test-env])
AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
AC_OUTPUT
diff --git a/test-env b/test-env
new file mode 100755
index 0000000..acb0925
--- /dev/null
+++ b/test-env
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Guix Data Service -- Information about Guix over time
+# Copyright © 2019 Christopher Baines <mail@cbaines.net>
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+
+export GUIX_DATA_SERVICE_DATABASE_PARAMSTRING=${GUIX_DATA_SERVICE_DATABASE_PARAMSTRING:-'dbname=guix_data_service_test user=guix_data_service'}
+
+"/home/chris/Projects/Guix/guix-data-service/pre-inst-env" "$@"
+exit $?
diff --git a/tests/model-derivation.scm b/tests/model-derivation.scm
new file mode 100644
index 0000000..52b113b
--- /dev/null
+++ b/tests/model-derivation.scm
@@ -0,0 +1,18 @@
+(define-module (test-model-derivation)
+ #:use-module (srfi srfi-64)
+ #:use-module (guix-data-service database)
+ #:use-module (guix-data-service model derivation))
+
+(test-begin "test-model-derivation")
+
+(with-postgresql-connection
+ (lambda (conn)
+ (test-equal "valid-systems"
+ '()
+ (valid-systems conn))
+
+ (test-equal "count-derivations"
+ '("0")
+ (count-derivations conn))))
+
+(test-end)