0.3.1: never overwrite outputs (seconds + -N suffix); OpenOnComplete (folder|pdf|none) on Windows+macOS; hold jobs on missing/invalid key (401/403) with one native sign-in prompt and auto-retry; macOS pkg in-installer key flow (mac-key-setup); Windows release installer (no debug naming, errors-only log, options page); VERAE_LOG_LEVEL=debug switch
This commit is contained in:
parent
bfc7d4e485
commit
e960883a0a
1 changed files with 1804 additions and 378 deletions
|
|
@ -103,3 +103,46 @@ func TestRunVeraeRendersLocalCert(t *testing.T) {
|
|||
t.Fatal("not a pdf")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunNeverOverwritesSameName(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
out := filepath.Join(dir, "out")
|
||||
n := 0
|
||||
client := &veraeapi.Client{
|
||||
Channel: auth.ChannelZapier,
|
||||
ZapierBase: "https://zap.test",
|
||||
XVeraeToken: "xVerae-x",
|
||||
HTTPDo: func(req *http.Request) (*http.Response, error) {
|
||||
n++
|
||||
// same receipt id every time, to also exercise cert-name collisions
|
||||
body := `{"receipt_id":"bafySame"}`
|
||||
return &http.Response{StatusCode: 200, Body: io.NopCloser(strings.NewReader(body)), Header: make(http.Header)}, nil
|
||||
},
|
||||
}
|
||||
var results []Result
|
||||
for i, content := range []string{"%PDF-1.4 first", "%PDF-1.4 second", "%PDF-1.4 third"} {
|
||||
src := filepath.Join(dir, "src"+string(rune('a'+i))+".pdf")
|
||||
_ = os.WriteFile(src, []byte(content), 0o600)
|
||||
res, err := Run(Options{SourcePDF: src, OutDir: out, DocumentName: "Printed 2026-10-03 192901.pdf", Channel: auth.ChannelZapier, Client: client})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
results = append(results, res)
|
||||
}
|
||||
wantOrig := []string{"Printed 2026-10-03 192901.pdf", "Printed 2026-10-03 192901-2.pdf", "Printed 2026-10-03 192901-3.pdf"}
|
||||
wantJSON := []string{"Printed-2026-10-03-192901.verae.json", "Printed-2026-10-03-192901-2.verae.json", "Printed-2026-10-03-192901-3.verae.json"}
|
||||
wantCert := []string{"Printed-2026-10-03-192901-verae-timestamp-bafySame.pdf", "Printed-2026-10-03-192901-2-verae-timestamp-bafySame.pdf", "Printed-2026-10-03-192901-3-verae-timestamp-bafySame.pdf"}
|
||||
for i, r := range results {
|
||||
if filepath.Base(r.OriginalPDF) != wantOrig[i] || filepath.Base(r.ReceiptJSON) != wantJSON[i] || filepath.Base(r.CertificatePDF) != wantCert[i] {
|
||||
t.Fatalf("job %d: %s | %s | %s", i, filepath.Base(r.OriginalPDF), filepath.Base(r.ReceiptJSON), filepath.Base(r.CertificatePDF))
|
||||
}
|
||||
}
|
||||
if b, _ := os.ReadFile(results[0].OriginalPDF); string(b) != "%PDF-1.4 first" {
|
||||
t.Fatalf("first original overwritten: %q", b)
|
||||
}
|
||||
// a pre-existing cert with the target name is never overwritten
|
||||
p, err := writeExclusive(out, "Printed-2026-10-03-192901-verae-timestamp-bafySame", ".pdf", []byte("x"))
|
||||
if err != nil || filepath.Base(p) != "Printed-2026-10-03-192901-verae-timestamp-bafySame-2.pdf" {
|
||||
t.Fatal(p, err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue