diff options
author | Ludovic Courtès <ludo@gnu.org> | 2017-11-28 22:41:57 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-11-28 23:34:25 +0100 |
commit | e755692bc1795382b2f91fc9763a690c02899954 (patch) | |
tree | b96ff6e18656cc552a4bb7a0dbfb2a19771bdf2b | |
parent | 410349347a7f38b7052d7574a629dd2660d018e0 (diff) | |
download | guix-e755692bc1795382b2f91fc9763a690c02899954.tar.gz |
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.
-rw-r--r-- | gnu/tests/version-control.scm | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm index 5a3937cfed..405b786d08 100644 --- a/gnu/tests/version-control.scm +++ b/gnu/tests/version-control.scm @@ -30,14 +30,38 @@ #:use-module (gnu packages version-control) #:use-module (guix gexp) #:use-module (guix store) + #:use-module (guix modules) #:export (%test-cgit)) +(define README-contents + "Hello! This is what goes inside the 'README' file.") + (define %make-git-repository ;; Create Git repository in /srv/git/test. - #~(begin - (mkdir-p "/srv/git/test") - (system* (string-append #$git "/bin/git") "-C" "/srv/git/test" - "init" "--bare"))) + (with-imported-modules (source-module-closure + '((guix build utils))) + #~(begin + (use-modules (guix build utils)) + + (let ((git (string-append #$git "/bin/git"))) + (mkdir-p "/tmp/test-repo") + (with-directory-excursion "/tmp/test-repo" + (call-with-output-file "/tmp/test-repo/README" + (lambda (port) + (display #$README-contents port))) + (invoke git "config" "--global" "user.email" "charlie@example.org") + (invoke git "config" "--global" "user.name" "A U Thor") + (invoke git "init") + (invoke git "add" ".") + (invoke git "commit" "-m" "That's a commit.")) + + (mkdir-p "/srv/git") + (rename-file "/tmp/test-repo/.git" "/srv/git/test"))))) + +(define %test-repository-service + ;; Service that creates /srv/git/test. + (simple-service 'make-git-repository activation-service-type + %make-git-repository)) (define %cgit-configuration-nginx (list @@ -68,8 +92,7 @@ (service cgit-service-type (cgit-configuration (nginx %cgit-configuration-nginx))) - (simple-service 'make-git-repository activation-service-type - %make-git-repository)))) + %test-repository-service))) (operating-system (inherit base-os) (packages (cons* git @@ -161,7 +184,9 @@ HTTP-PORT." (test-url "/test") (test-url "/test/log") (test-url "/test/tree") + (test-url "/test/tree/README") (test-url "/test/does-not-exist" 404) + (test-url "/test/tree/does-not-exist" 404) (test-url "/does-not-exist" 404)) (test-end) |