Subject: [PATCH 2/4] tests: mympd: Simplify test.

From: Bruno Victal <[email-masked]>
Date: Fri, 15 Dec 2023 21:02:37 +0000

* gnu/tests/audio.scm: (run-mympd-test): Restyle.
Remove dhcp-client-service-type. Remove port-forwards and refactor http-head
test to happen within the VM instead of the host.
---
 gnu/tests/audio.scm | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/gnu/tests/audio.scm b/gnu/tests/audio.scm
index acb91293e8..a0ab54da2a 100644
--- a/gnu/tests/audio.scm
+++ b/gnu/tests/audio.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Peter Mikkelsen <[email-masked]>
-;;; Copyright © 2022 Bruno Victal <[email-masked]>
+;;; Copyright © 2022–2023 Bruno Victal <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -81,23 +81,17 @@ (define %test-mpd
    (value (run-mpd-test))))
 
 (define (run-mympd-test)
-  (define os (marionette-operating-system
-              (simple-operating-system (service dhcp-client-service-type)
-                                       (service mympd-service-type))
-              #:imported-modules '((gnu services herd))))
+  (define os
+    (marionette-operating-system
+     (simple-operating-system (service mympd-service-type))
+     #:imported-modules '((gnu services herd))))
 
-  (define vm
-    (virtual-machine
-     (operating-system os)
-     (port-forwardings '((8080 . 80)))))
+  (define vm (virtual-machine os))
 
   (define test
     (with-imported-modules '((gnu build marionette))
       #~(begin
           (use-modules (srfi srfi-64)
-                       (srfi srfi-8)
-                       (web client)
-                       (web response)
                        (gnu build marionette))
 
           (define marionette
@@ -106,18 +100,23 @@ (define (run-mympd-test)
           (test-runner-current (system-test-runner #$output))
           (test-begin "mympd")
           (test-assert "service is running"
-            (marionette-eval '(begin
-                                (use-modules (gnu services herd))
-
-                                (start-service 'mympd))
-                             marionette))
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (start-service 'mympd))
+             marionette))
 
           (test-assert "HTTP port ready"
             (wait-for-tcp-port 80 marionette))
 
           (test-equal "http-head"
             200
-            (receive (x _) (http-head "http://localhost:8080") (response-code x)))
+            (marionette-eval
+             '(begin
+                (use-modules (web client)
+                             (web response))
+                (response-code (http-head "http://localhost")))
+             marionette))
 
           (test-end))))
   (gexp->derivation "mympd-test" test))
-- 
2.41.0