aboutsummaryrefslogtreecommitdiff
path: root/gnu/tests/version-control.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-11-28 23:18:35 +0100
committerLudovic Courtès <ludo@gnu.org>2017-11-28 23:34:25 +0100
commit87dad874c929702192ece2d38a7a583b8202f348 (patch)
treed1b7a4b8d3ebae4acef9968be12a23d3baa86f4b /gnu/tests/version-control.scm
parente755692bc1795382b2f91fc9763a690c02899954 (diff)
downloadguix-87dad874c929702192ece2d38a7a583b8202f348.tar
guix-87dad874c929702192ece2d38a7a583b8202f348.tar.gz
tests: Add 'git-http' test.
* gnu/tests/version-control.scm (%git-nginx-configuration) (%git-http-os, %test-git-http): New variables. (run-git-http-test): New procedure.
Diffstat (limited to 'gnu/tests/version-control.scm')
-rw-r--r--gnu/tests/version-control.scm94
1 files changed, 93 insertions, 1 deletions
diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm
index 405b786d08..2cbacf0ef9 100644
--- a/gnu/tests/version-control.scm
+++ b/gnu/tests/version-control.scm
@@ -31,7 +31,8 @@
#:use-module (guix gexp)
#:use-module (guix store)
#:use-module (guix modules)
- #:export (%test-cgit))
+ #:export (%test-cgit
+ %test-git-http))
(define README-contents
"Hello! This is what goes inside the 'README' file.")
@@ -199,3 +200,94 @@ HTTP-PORT."
(name "cgit")
(description "Connect to a running Cgit server.")
(value (run-cgit-test))))
+
+
+;;;
+;;; Git server.
+;;;
+
+(define %git-nginx-configuration
+ (nginx-configuration
+ (server-blocks
+ (list
+ (nginx-server-configuration
+ (http-port 19418)
+ (https-port #f)
+ (ssl-certificate #f)
+ (ssl-certificate-key #f)
+ (locations
+ (list (git-http-nginx-location-configuration
+ (git-http-configuration (export-all? #t)
+ (uri-path "/git"))))))))))
+
+(define %git-http-os
+ (simple-operating-system
+ (dhcp-client-service)
+ (service fcgiwrap-service-type)
+ (service nginx-service-type %git-nginx-configuration)
+ %test-repository-service))
+
+(define* (run-git-http-test #:optional (http-port 19418))
+ (define os
+ (marionette-operating-system
+ %git-http-os
+ #:imported-modules '((gnu services herd)
+ (guix combinators))))
+
+ (define vm
+ (virtual-machine
+ (operating-system os)
+ (port-forwardings `((8080 . ,http-port)))))
+
+ (define test
+ (with-imported-modules '((gnu build marionette)
+ (guix build utils))
+ #~(begin
+ (use-modules (srfi srfi-64)
+ (rnrs io ports)
+ (gnu build marionette)
+ (guix build utils))
+
+ (define marionette
+ (make-marionette (list #$vm)))
+
+ (mkdir #$output)
+ (chdir #$output)
+
+ (test-begin "git-http")
+
+ ;; Wait for nginx to be up and running.
+ (test-eq "nginx running"
+ 'running!
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (start-service 'nginx)
+ 'running!)
+ marionette))
+
+ ;; Make sure Git test repository is created.
+ (test-assert "Git test repository"
+ (marionette-eval
+ '(file-exists? "/srv/git/test")
+ marionette))
+
+ ;; Make sure we can clone the repo from the host.
+ (test-equal "clone"
+ '#$README-contents
+ (begin
+ (invoke #$(file-append git "/bin/git") "clone" "-v"
+ "http://localhost:8080/git/test" "/tmp/clone")
+ (call-with-input-file "/tmp/clone/README"
+ get-string-all)))
+
+ (test-end)
+ (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+ (gexp->derivation "git-http" test))
+
+(define %test-git-http
+ (system-test
+ (name "git-http")
+ (description "Connect to a running Git HTTP server.")
+ (value (run-git-http-test))))