commit a2259cdf6a0abfc84c6f2330b9caecec1f22cba2
parent edf534e3b8dc364ff9a00f995f2d300ec68f827e
Author: Sean Enck <sean@ttypty.com>
Date: Sun, 8 Dec 2024 10:49:10 -0500
tests for pwgen
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/tests/expected.log b/tests/expected.log
@@ -165,3 +165,5 @@ clipboard will clear in 3 seconds
Wrong password? HMAC-SHA256 of header mismatching
no store set
keys/k/one2
+Abc
+bb
diff --git a/tests/main.go b/tests/main.go
@@ -317,6 +317,20 @@ func test(profile string) error {
r.run("", "ls")
setConfig(r.config)
r.run("", "ls")
+
+ // pwgen
+ c["pwgen.words_command"] = "[\"/bin/sh\", \"-c\", \"echo abc abc | tr ' ' '\\n'\"]"
+ c["pwgen.word_count"] = "1"
+ r.writeConfig(c)
+ r.run("", "pwgen")
+ c["pwgen.template"] = "\"{{range [%]idx, [%]val := .}}{{if lt [%]val.Position.End 5}}{{ [%]val.Text }}{{end}}{{end}}\""
+ c["pwgen.characters"] = c.quoteString("b")
+ c["pwgen.word_count"] = "2"
+ c["pwgen.title"] = "false"
+ r.writeConfig(c)
+ r.run("", "pwgen")
+
+ // cleanup and diff results
tmpFile := fmt.Sprintf("%s.tmp", r.log)
for _, item := range []string{"'s/\"modtime\": \"[0-9].*$/\"modtime\": \"XXXX-XX-XX\",/g'", "'s/^[0-9][0-9][0-9][0-9][0-9][0-9]$/XXXXXX/g'"} {
exec.Command("/bin/sh", "-c", fmt.Sprintf("sed %s %s > %s", item, r.log, tmpFile)).Run()