aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredrik Salomonsson <plattfot@gmail.com>2020-05-11 17:00:30 -0700
committerFredrik Salomonsson <plattfot@gmail.com>2020-05-11 17:00:30 -0700
commitc0b982bb557f23a60c3d0f934c519abd7f749a88 (patch)
treecaae65ed34b0adddb72d8ae984e877a1078d1d2a
parent04eb740c677beb6f54d591d198451d86986f6716 (diff)
downloadpinentry-rofi-c0b982bb557f23a60c3d0f934c519abd7f749a88.tar.gz
Add test for empty password and string-empty?
-rwxr-xr-xpinentry-rofi.scm1
-rwxr-xr-xtest.scm48
2 files changed, 47 insertions, 2 deletions
diff --git a/pinentry-rofi.scm b/pinentry-rofi.scm
index 76fc0df..c0e7cd5 100755
--- a/pinentry-rofi.scm
+++ b/pinentry-rofi.scm
@@ -52,6 +52,7 @@
html-newline
html-underline
html-<
+ string-empty?
hex->char
input-string
diff --git a/test.scm b/test.scm
index 226631f..e7051b3 100755
--- a/test.scm
+++ b/test.scm
@@ -69,6 +69,8 @@
(test-equal "_Ok%0A_Cancel" (escape-underscore "__Ok%0A__Cancel"))
(test-equal "_Ok&#10;_Cancel" (escape-underscore "__Ok&#10;__Cancel"))
+(test-assert (string-empty? ""))
+(test-assert (not (string-empty? "foo")))
(test-end "utils")
(test-equal "This is one line\nThis is another%OA"
@@ -294,7 +296,7 @@
buttons
only-match)
(test-equal "Prompt" prompt)
- (test-equal (format #f "~a\n~a" error description)
+ (test-equal (format #f "~a&#10;~a" error description)
message)
(test-assert (not visibility))
(test-assert (not only-match))
@@ -303,6 +305,48 @@
"password")))
(test-equal (format #f "D password") output)))
+ (set! output "")
+ (with-output-to-port
+ fake-port
+ (lambda ()
+ (test-assert (pinentry-getpin pinentry "GETPIN"
+ (lambda* (#:key (env '())
+ visibility
+ (prompt ">")
+ message
+ buttons
+ only-match)
+ (test-equal "Prompt" prompt)
+ (test-equal (format #f "~a&#10;~a" error description)
+ message)
+ (test-assert (not visibility))
+ (test-assert (not only-match))
+ (test-assert (not buttons))
+ (test-equal `(("DISPLAY" . ,display)) env)
+ "")))
+ (test-equal (format #f "ERR 83886179 Operation cancelled <rofi>\n") output)))
+
+ (set! output "")
+ (with-output-to-port
+ fake-port
+ (lambda ()
+ (test-assert (pinentry-getpin pinentry "GETPIN"
+ (lambda* (#:key (env '())
+ visibility
+ (prompt ">")
+ message
+ buttons
+ only-match)
+ (test-equal "Prompt" prompt)
+ (test-equal (format #f "~a&#10;~a" error description)
+ message)
+ (test-assert (not visibility))
+ (test-assert (not only-match))
+ (test-assert (not buttons))
+ (test-equal `(("DISPLAY" . ,display)) env)
+ " ")))
+ (test-equal (format #f "ERR 83886179 Operation cancelled <rofi>\n") output)))
+
(test-assert (not (pinentry-getinfo pinentry " GETPIN")))
(test-assert (not (pinentry-getinfo pinentry "Foo"))))
@@ -350,7 +394,7 @@
buttons
only-match)
(test-equal ">" prompt)
- (test-equal (format #f "~a\n~a" error description)
+ (test-equal (format #f "~a&#10;~a" error description)
message)
(test-assert visibility)
(test-assert only-match)