Skip to content

Commit c2aa369

Browse files
committed
fix(hooks): use delivery-neutral Gmail watch warning
1 parent 89fcda4 commit c2aa369

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/hooks/gmail-watcher.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
44

55
const mocks = vi.hoisted(() => ({
66
hasBinary: vi.fn(() => true),
7+
logger: {
8+
error: vi.fn(),
9+
info: vi.fn(),
10+
warn: vi.fn(),
11+
},
712
resolveExecutable: vi.fn((name: string) => name),
813
runCommandWithTimeout: vi.fn(),
914
spawn: vi.fn(),
@@ -29,6 +34,10 @@ vi.mock("../process/exec.js", () => ({
2934
runCommandWithTimeout: mocks.runCommandWithTimeout,
3035
}));
3136

37+
vi.mock("../logging/subsystem.js", () => ({
38+
createSubsystemLogger: () => mocks.logger,
39+
}));
40+
3241
const { startGmailWatcher, stopGmailWatcher } = await import("./gmail-watcher.js");
3342

3443
function createGmailConfig(account = "[email protected]") {
@@ -74,6 +83,9 @@ describe("startGmailWatcher", () => {
7483
beforeEach(async () => {
7584
await stopGmailWatcher();
7685
mocks.hasBinary.mockReturnValue(true);
86+
mocks.logger.error.mockClear();
87+
mocks.logger.info.mockClear();
88+
mocks.logger.warn.mockClear();
7789
mocks.resolveExecutable.mockImplementation((name: string) => name);
7890
mocks.runCommandWithTimeout.mockReset();
7991
mocks.spawn.mockReset();
@@ -123,6 +135,21 @@ describe("startGmailWatcher", () => {
123135
);
124136
});
125137

138+
it("uses pull wording when watch registration fails before pull runner start", async () => {
139+
mocks.runCommandWithTimeout
140+
.mockResolvedValueOnce({ code: 0, stdout: "", stderr: "" })
141+
.mockResolvedValueOnce({ code: 1, stdout: "", stderr: "watch failed" });
142+
143+
await expect(startGmailWatcher(createGmailPullConfig())).resolves.toEqual({
144+
started: true,
145+
});
146+
147+
expect(mocks.spawn).toHaveBeenCalledTimes(1);
148+
expect(mocks.logger.warn).toHaveBeenCalledWith(
149+
"gmail watch start failed, but continuing with pull delivery runner",
150+
);
151+
});
152+
126153
it("does not spawn pull delivery when installed gog lacks pull support", async () => {
127154
mocks.runCommandWithTimeout.mockResolvedValue({
128155
code: 1,

src/hooks/gmail-watcher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ export async function startGmailWatcher(
370370
return cancelledGmailWatcherStart(runtimeConfig);
371371
}
372372
if (!watchStarted) {
373-
log.warn("gmail watch start failed, but continuing with serve");
373+
const deliveryMode = isGmailHookPushRuntimeConfig(runtimeConfig) ? "push" : "pull";
374+
log.warn(`gmail watch start failed, but continuing with ${deliveryMode} delivery runner`);
374375
}
375376

376377
// Spawn the gog delivery process

0 commit comments

Comments
 (0)