diff mbox series

[bug#63877,2/2] tests: web: Test environment variables are set for php-fpm.

Message ID 20240217232151.12507-4-guix@twilken.net
State New
Headers show
Series [bug#63877,1/2] gnu: services: web: Allow specifying extra php-fpm environment variables. | expand

Commit Message

Timo Wilken Feb. 17, 2024, 11:21 p.m. UTC
From: Timo Wilken <guix@twilken.net>

Test the new `environment-variables' field of <php-fpm-configuration> by
looking for a sentinel variable and value in the output of `phpinfo()'.

* gnu/tests/web.scm (run-php-fpm-test): Add test case.
---
 gnu/tests/web.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 16dc6bea49..f1688bfd3a 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -272,7 +272,10 @@  (define %php-fpm-os
   ;; Operating system under test.
   (simple-operating-system
    (service dhcp-client-service-type)
-   (service php-fpm-service-type)
+   (service php-fpm-service-type
+            (php-fpm-configuration
+             (environment-variables
+              '(("GUIX_TEST_PHPFPM_ENV" . "sentinel")))))
    (service nginx-service-type
             (nginx-configuration
              (server-blocks %php-fpm-nginx-server-blocks)))
@@ -345,6 +348,13 @@  (define marionette
                   (and matches
                        (match:substring matches 0))))))
 
+          (test-assert "php environment variable is applied"
+            (let-values (((response text)
+                          (http-get "http://localhost:8080/index.php"
+                                    #:decode-body? #t)))
+              (and (string-contains text "GUIX_TEST_PHPFPM_ENV")
+                   (string-contains text "sentinel"))))
+
           (test-end))))
 
   (gexp->derivation "php-fpm-test" test))