Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fishinthecalculator committed May 27, 2024
1 parent 14b1d4c commit b051a3c
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions tests/test-sops.scm
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,44 @@
#:use-module (ice-9 match)
#:export (with-test-group))

(define (sops:test-runner)
(let ((runner (test-runner-null))
(num-passed 0)
(num-failed 0))
(test-runner-on-test-end! runner
(lambda (runner)
(format #t "[~a] line:~a, test: ~a\n"
(test-result-ref runner 'result-kind)
(test-result-ref runner 'source-line)
(test-runner-test-name runner))
(case (test-result-kind runner)
((pass xpass) (set! num-passed (1+ num-passed)))
((fail xfail)
(if (test-result-ref runner 'expected-value)
(format #t "~a\n -> expected: ~s\n -> obtained: ~s\n"
(string-join (test-runner-group-path runner) "/")
(test-result-ref runner 'expected-value)
(test-result-ref runner 'actual-value)))
(set! num-failed (1+ num-failed)))
(else #t))))
(test-runner-on-final! runner
(lambda (runner)
(format #t "Source: ~a\npass = ~a, fail = ~a\n"
(test-result-ref runner 'source-file) num-passed num-failed)
(zero? num-failed)))
runner))

(define-syntax-rule (with-test-group name . expr)
(begin (test-begin name) expr (test-end name)))

(test-runner-factory sops:test-runner)

(with-test-group "key->file-name"
(lambda _
(let ((results '(("[\"private\"]" "private")
("[632]" "632")
("[3][\"private\"]" "3-private")
("[\"wireguard\"][18][\"private\"]" "wireguard-18-private"))))
("[3][\"private\"]" "3/private")
("[\"wireguard\"][18][\"private\"]" "wireguard/18/private"))))
(for-each
(match-lambda
((input expected)
Expand Down

0 comments on commit b051a3c

Please sign in to comment.