From 64203dd4ea7d70b2d53e69dbc63fc67bff4c7820 Mon Sep 17 00:00:00 2001 From: Rodion Goritskov Date: Mon, 14 Oct 2024 23:48:17 +0400 Subject: gnu: miniflux: Remove unnecessary Shepherd dependency. * rodion/services/miniflux.scm miniflux: Remove unnecessary dependency from service. * rodion/tests/services.scm: Make Miniflux tests more stable. Add page open test case. --- rodion/services/miniflux.scm | 2 +- rodion/tests/services.scm | 45 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/rodion/services/miniflux.scm b/rodion/services/miniflux.scm index 39699f0..e4ece2c 100644 --- a/rodion/services/miniflux.scm +++ b/rodion/services/miniflux.scm @@ -73,7 +73,7 @@ (list (shepherd-service (documentation "Run Miniflux server") (provision '(miniflux)) - (requirement '(networking postgresql)) + (requirement '(postgres)) (start #~(make-forkexec-constructor (list (string-append #$miniflux "/bin/miniflux") "-config-file" #$config-file) diff --git a/rodion/tests/services.scm b/rodion/tests/services.scm index 758be89..e5f7571 100644 --- a/rodion/tests/services.scm +++ b/rodion/tests/services.scm @@ -12,13 +12,35 @@ #:use-module (rodion services miniflux) #:use-module (guix gexp)) +(define retry-on-error + #~(lambda* (f #:key times delay) + (let loop ((attempt 1)) + (match (catch + #t + (lambda () + (cons #t + (f))) + (lambda args + (cons #f + args))) + ((#t . return-value) + return-value) + ((#f . error-args) + (if (>= attempt times) + error-args + (begin + (sleep delay) + (loop (+ 1 attempt))))))))) + (define %miniflux-os (simple-operating-system (service dhcp-client-service-type) (service postgresql-service-type (postgresql-configuration (postgresql postgresql-15))) - (service miniflux-service-type))) + (service miniflux-service-type + (miniflux-configuration + (listen-addr "0.0.0.0:8080"))))) (define* (run-miniflux-test name test-os) (define os @@ -32,13 +54,19 @@ (define vm (virtual-machine (operating-system os) + (memory-size 512) (port-forwardings `((8080 . ,forwarded-port))))) (define test (with-imported-modules '((gnu build marionette)) #~(begin (use-modules (srfi srfi-64) - (gnu build marionette)) + (srfi srfi-11) + (gnu build marionette) + (web client) + (web uri) + (web response) + (ice-9 match)) (define marionette (make-marionette (list #$vm))) @@ -60,6 +88,19 @@ (test-assert "Miniflux TCP port ready, IPv4" (wait-for-tcp-port #$forwarded-port marionette)) + + (test-assert "Miniflux login page is opened" + (begin + (wait-for-tcp-port #$forwarded-port marionette) + (#$retry-on-error + (lambda () + (let-values (((response text) + (http-get + #$(format #f "http://localhost:~A/" forwarded-port) + #:decode-body? #t))) + (string-contains text "Sign In - Miniflux"))) + #:times 10 + #:delay 5))) (test-end)))) (gexp->derivation "miniflux-test" test)) -- cgit v1.2.3