aboutsummaryrefslogtreecommitdiff
path: root/tests/services
diff options
context:
space:
mode:
Diffstat (limited to 'tests/services')
-rw-r--r--tests/services/configuration.scm28
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 86a36a388d..0debf8095b 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -27,6 +27,9 @@
(test-begin "services-configuration")
+(define (serialize-number field value)
+ (format #f "~a=~a" field value))
+
;;;
;;; define-configuration macro.
@@ -47,7 +50,6 @@
80
(port-configuration-cs-port (port-configuration-cs)))
-(define serialize-number "")
(define-configuration port-configuration-ndv
(port (number) "The port number."))
@@ -101,15 +103,31 @@
(define-maybe number)
(define-configuration config-with-maybe-number
- (port (maybe-number 80) "The port number."))
-
-(define (serialize-number field value)
- (format #f "~a=~a" field value))
+ (port (maybe-number 80) "")
+ (count maybe-number ""))
(test-equal "maybe value serialization"
"port=80"
(serialize-maybe-number "port" 80))
+(define (config-with-maybe-number->string x)
+ (eval (gexp->approximate-sexp
+ (serialize-configuration x config-with-maybe-number-fields))
+ (current-module)))
+
+(test-equal "maybe value serialization of the instance"
+ "port=42count=43"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42)
+ (count 43))))
+
+(test-equal "maybe value serialization of the instance, unspecified"
+ "port=42"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42))))
+
(define-maybe/no-serialization string)
(define-configuration config-with-maybe-string/no-serialization