summaryrefslogtreecommitdiff
path: root/gnu/tests/version-control.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-11-28 22:41:57 +0100
committerLudovic Courtès <ludo@gnu.org>2017-11-28 23:34:25 +0100
commite755692bc1795382b2f91fc9763a690c02899954 (patch)
treeb96ff6e18656cc552a4bb7a0dbfb2a19771bdf2b /gnu/tests/version-control.scm
parent410349347a7f38b7052d7574a629dd2660d018e0 (diff)
tests: cgit: Add a file to the test repository.
* gnu/tests/version-control.scm (README-contents): New variable. (%make-git-repository): Add a 'README' file to the repo. (%test-repository-service): New variable. (%cgit-os): Use it. (run-cgit-test): Test /test/tree/README and /test/tree/does-not-exist.
Diffstat (limited to 'gnu/tests/version-control.scm')
-rw-r--r--gnu/tests/version-control.scm37
1 files changed, 31 insertions, 6 deletions
diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm
index 5a3937cfedd..405b786d082 100644
--- a/gnu/tests/version-control.scm
+++ b/gnu/tests/version-control.scm
@@ -30,14 +30,38 @@
30 #:use-module (gnu packages version-control) 30 #:use-module (gnu packages version-control)
31 #:use-module (guix gexp) 31 #:use-module (guix gexp)
32 #:use-module (guix store) 32 #:use-module (guix store)
33 #:use-module (guix modules)
33 #:export (%test-cgit)) 34 #:export (%test-cgit))
34 35
36(define README-contents
37 "Hello! This is what goes inside the 'README' file.")
38
35(define %make-git-repository 39(define %make-git-repository
36 ;; Create Git repository in /srv/git/test. 40 ;; Create Git repository in /srv/git/test.
37 #~(begin 41 (with-imported-modules (source-module-closure
38 (mkdir-p "/srv/git/test") 42 '((guix build utils)))
39 (system* (string-append #$git "/bin/git") "-C" "/srv/git/test" 43 #~(begin
40 "init" "--bare"))) 44 (use-modules (guix build utils))
45
46 (let ((git (string-append #$git "/bin/git")))
47 (mkdir-p "/tmp/test-repo")
48 (with-directory-excursion "/tmp/test-repo"
49 (call-with-output-file "/tmp/test-repo/README"
50 (lambda (port)
51 (display #$README-contents port)))
52 (invoke git "config" "--global" "user.email" "charlie@example.org")
53 (invoke git "config" "--global" "user.name" "A U Thor")
54 (invoke git "init")
55 (invoke git "add" ".")
56 (invoke git "commit" "-m" "That's a commit."))
57
58 (mkdir-p "/srv/git")
59 (rename-file "/tmp/test-repo/.git" "/srv/git/test")))))
60
61(define %test-repository-service
62 ;; Service that creates /srv/git/test.
63 (simple-service 'make-git-repository activation-service-type
64 %make-git-repository))
41 65
42(define %cgit-configuration-nginx 66(define %cgit-configuration-nginx
43 (list 67 (list
@@ -68,8 +92,7 @@
68 (service cgit-service-type 92 (service cgit-service-type
69 (cgit-configuration 93 (cgit-configuration
70 (nginx %cgit-configuration-nginx))) 94 (nginx %cgit-configuration-nginx)))
71 (simple-service 'make-git-repository activation-service-type 95 %test-repository-service)))
72 %make-git-repository))))
73 (operating-system 96 (operating-system
74 (inherit base-os) 97 (inherit base-os)
75 (packages (cons* git 98 (packages (cons* git
@@ -161,7 +184,9 @@ HTTP-PORT."
161 (test-url "/test") 184 (test-url "/test")
162 (test-url "/test/log") 185 (test-url "/test/log")
163 (test-url "/test/tree") 186 (test-url "/test/tree")
187 (test-url "/test/tree/README")
164 (test-url "/test/does-not-exist" 404) 188 (test-url "/test/does-not-exist" 404)
189 (test-url "/test/tree/does-not-exist" 404)
165 (test-url "/does-not-exist" 404)) 190 (test-url "/does-not-exist" 404))
166 191
167 (test-end) 192 (test-end)