(use-modules (srfi srfi-64) (srfi srfi-13) (fruix installer) (fruix system freebsd)) (define (make-test-state) (installer-state #:operating-system #f #:storage-layout (default-freebsd-efi-ufs-storage-layout #:device #f) #:target-device #f #:host-name #f #:root-size #f #:disk-capacity #f #:network-mode default-installer-network-mode #:selected-step 'welcome #:metadata '())) (define (response-state response) (assoc-ref response 'state)) (define (response-result response) (assoc-ref response 'result)) (test-begin "installer-basic") (let ((candidates (installer-target-device-candidates (installer-state #:storage-layout (default-freebsd-efi-ufs-storage-layout #:device #f) #:target-device "/dev/ada0" #:host-name "seed" #:selected-step 'target-disk) #:kern-disks "cd0 ada1 ada0 md0 pass0 nvd0"))) (test-equal "target-device candidate filtering" '("/dev/ada0" "/dev/ada1" "/dev/nvd0") candidates)) (let* ((response (run-installer-command-script (make-test-state) '((action next) (set target-device "/dev/ada0") (action next) (action next) (set host-name "apollo") (action next) (set network-mode dhcp) (action next) (action proceed)) #:target-devices '("/dev/ada0" "/dev/ada1"))) (state (response-state response))) (test-equal "happy-path script result" 'proceed (response-result response)) (test-equal "happy-path final step" 'install (installer-state-selected-step state)) (test-equal "happy-path target device" "/dev/ada0" (installer-state-target-device state)) (test-equal "happy-path host name" "apollo" (installer-state-host-name state)) (test-equal "happy-path network mode" 'dhcp (installer-state-network-mode state)) (test-assert "happy-path ready for install" (installer-state-ready-for-install? state)) (test-assert "happy-path review text mentions host" (string-contains (installer-final-summary-text state) "host-name: apollo"))) (let* ((response (run-installer-command-script (make-test-state) '((action next) (action next)) #:target-devices '("/dev/ada0"))) (state (response-state response))) (test-equal "missing target device yields error" 'error (response-result response)) (test-equal "missing target device stays on target step" 'target-disk (installer-state-selected-step state))) (let* ((response (run-installer-command-script (make-test-state) '((action next) (set target-device "/dev/ada0") (action next) (action back)) #:target-devices '("/dev/ada0"))) (state (response-state response))) (test-equal "back navigation returns to target-disk" 'target-disk (installer-state-selected-step state))) (let* ((response (installer-command-apply (make-test-state) '(action proceed) #:target-devices '("/dev/ada0")))) (test-equal "proceed only valid from summary/install" 'error (response-result response))) (test-end "installer-basic")