fix: close durable queue and runtime gaps
Quality / quality (ubuntu-latest) (push) Failing after 9m54s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-23 20:47:00 +05:30
parent 1a94179b5f
commit a9670c2a1c
19 changed files with 198 additions and 26 deletions
+30 -1
View File
@@ -1,5 +1,5 @@
import { expect, test } from "bun:test";
import { defineMail, defineMailTemplate } from "../src/index.ts";
import { defineMail, defineMailTemplate, sealedMailDriver } from "../src/index.ts";
test("mail templates render and sandbox blocks accidental recipients", async () => {
const sent: unknown[] = [];
@@ -16,3 +16,32 @@ test("mail templates render and sandbox blocks accidental recipients", async ()
expect(sent).toHaveLength(1);
await expect(mail.send({ to: "real@example.com", subject: "no" })).rejects.toThrow("SANDBOX");
});
test("sealed drivers decrypt lazily once and delegate send/test", async () => {
let opens = 0;
const sent: string[] = [];
const driver = sealedMailDriver({
sealedCredential: "ciphertext",
async unseal(value) {
opens++;
expect(value).toBe("ciphertext");
return "plaintext-secret";
},
create(credential) {
expect(credential).toBe("plaintext-secret");
return {
async send(message) {
sent.push(message.subject);
},
async test() {
return { ok: true };
},
};
},
});
expect(opens).toBe(0);
await driver.send({ to: "safe@example.test", subject: "one" });
expect(await driver.test?.()).toEqual({ ok: true });
expect(opens).toBe(1);
expect(sent).toEqual(["one"]);
});