From ef4fd5ab4fee64639dcd18ead2a82aa2235661fd Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 14 Apr 2019 10:08:11 +0100 Subject: Add an initial test Along with the buildsystem changes to make `make check` work. --- .gitignore | 4 ++++ Makefile.am | 13 +++++++++++++ configure.ac | 1 + test-env | 23 +++++++++++++++++++++++ tests/model-derivation.scm | 18 ++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100755 test-env create mode 100644 tests/model-derivation.scm 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 +# +# 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 +# . + +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) -- cgit v1.2.3