;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Adriano Peluso ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix 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 General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu tests trytond) #:use-module (gnu tests) #:use-module (gnu system) #:use-module (gnu system file-systems) #:use-module (gnu system shadow) #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu packages databases) #:use-module (gnu services databases) #:use-module (gnu services networking) #:use-module (gnu services networking) #:use-module (gnu services trytond) #:use-module (guix gexp) #:use-module (guix store) #:export (%test-trytond)) (define %trytond-os (simple-operating-system (postgresql-service #:locale "it_IT.UTF-8") (service trytond-service-type))) (define* (run-trytond-test) "Run tests in %TRYTOND-OS." (define os (marionette-operating-system %trytond-os #:imported-modules '((gnu services herd) (guix combinators)))) (define vm (virtual-machine (operating-system os) (memory-size 512))) (define test (with-imported-modules '((gnu build marionette)) #~(begin (use-modules (srfi srfi-11) (srfi srfi-64) (gnu build marionette)) (define marionette (make-marionette (list #$vm))) (mkdir #$output) (chdir #$output) (test-begin "trytond") (marionette-eval '(current-output-port (open-file "/dev/console" "w0")) marionette) (marionette-eval '(current-error-port (open-file "/dev/console" "w0")) marionette) (test-assert "service running" (marionette-eval '(begin (use-modules (gnu services herd)) (match (start-service 'trytond) (#f #f) (('service response-parts ...) (match (assq-ref response-parts 'running) ((pid) (number? pid)))))) marionette)) ; (test-assert "tryton postgres role exists" ; (marionette-eval ; '(begin ; (use-modules (gnu services herd)) ; (match (start-service 'trytond) ; (#f #f) ;(('service response-parts ...) ; chiamare psql con open-pipe* ? ; no, restituisce stringe ; ci vorrebbe squee ; (match (assq-ref response-parts 'running) ; ((pid) (number? pid)))))) ; marionette)))) (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) (gexp->derivation "trytond-test" test)) (define %test-trytond (system-test (name "trytond") (description "Test the Trytond service.") (value (run-trytond-test))))