1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
;;; Guile-Git --- GNU Guile bindings of libgit2
;;; Copyright © 2022 André Batista <nandre@riseup.net>
;;;
;;; This file is part of Guile-Git.
;;;
;;; Guile-Git 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.
;;;
;;; Guile-Git 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 Guile-Git. If not, see <http://www.gnu.org/licenses/>.
(define-module (tests settings)
#:use-module (git)
#:use-module (git configuration)
#:use-module (tests helpers)
#:use-module (srfi srfi-64))
(test-begin "settings")
(libgit2-init!)
(with-repository "simple" directory
(test-equal "disable owner validation"
#f
((lambda ()
(set-owner-validation! #f)
(owner-validation?))))
(test-equal "enable owner validation"
#t
((lambda ()
(set-owner-validation! #t)
(owner-validation?))))
;; With libgit2 < 1.8, this throws ("invalid argument: 'string'").
(catch 'git-error user-agent
(lambda _ (test-skip 1)))
(test-assert "default user-agent"
(or (string-prefix? "libgit2" (user-agent))
(string-null? (user-agent)))) ;on libgit2 1.3
(test-equal "set-user-agent!"
"GNU Guile"
(begin
(set-user-agent! "GNU Guile")
(user-agent)))
(unless %have-GIT_OPT_SET_USER_AGENT_PRODUCT? (test-skip 2))
(test-assert "default user-agent product"
(string-prefix? "git/" (user-agent-product)))
(test-equal "set-user-agent-product!"
"Guile-Git/1.2.3"
(let ((initial (user-agent-product)))
(set-user-agent-product! "Guile-Git/1.2.3")
(let ((after (user-agent-product)))
(set-user-agent-product! #f)
(and (string=? (user-agent-product) initial)
after))))
(unless %have-GIT_OPT_SET_HOMEDIR? (test-skip 2))
(test-equal "default home directory"
(or (getenv "HOME")
(passwd:dir (getpwuid (getuid))))
(home-directory))
(test-equal "set-home-directory!"
(getcwd)
(begin
(set-home-directory! (getcwd))
(home-directory)))
(test-equal "server timeout"
(if %have-GIT_OPT_SET_SERVER_CONNECT_TIMEOUT? 42 0)
(begin
(set-server-timeout! 42)
(server-timeout)))
(test-equal "server connection timeout"
(if %have-GIT_OPT_SET_SERVER_CONNECT_TIMEOUT? 77 0)
(begin
(set-server-connection-timeout! 77)
(server-connection-timeout))))
(libgit2-shutdown!)
(test-end)
|