mirror of
https://github.com/aculix/ticket-monitoring.git
synced 2026-10-27 07:15:51 +00:00
fix: treat District 'content not found' as waiting, not as a failure
A film that is announced but has no showtimes yet answers 400 with code 32, which is exactly the state you are monitoring for before a release. Counting that as a check failure meant pointing District at an upcoming film produced a false BROKEN alert every six minutes until the listing appeared. Code 32 now reports closed and carries a note through to the status endpoint and the daily heartbeat, so a typo'd content id still surfaces rather than looking like a quiet 'not open yet' forever. Other 400s, including the missing-parameter error, still fail loudly.
This commit is contained in:
1 parent
9442bca696
commit
67e97f5a6a
5 files changed
+75
-6
No files matched your search
@@ -104,3 +104,31 @@ test("bookmyshow: a not-yet-on-sale response has no widgets and extracts to noth
|
||||
assert.deepEqual(bms.extract(closed, CFG, B_PARAMS),
|
||||
{ matched: [], other: [], cinemaCount: 0, sessionCount: 0, showDates: [] });
|
||||
});
|
||||
|
||||
// The 400 branch decides between "waiting for a listing" and "something is wrong",
|
||||
// so it is worth pinning without a network.
|
||||
test("district: 400 code 32 is a waiting state, other 400s are failures", async () => {
|
||||
const realFetch = globalThis.fetch;
|
||||
const stub = (status, body) => {
|
||||
globalThis.fetch = async () => ({ status, json: async () => body });
|
||||
};
|
||||
const p = { movieCode: "X", contentId: "1", cityKey: "c", lat: "1", lng: "2" };
|
||||
try {
|
||||
stub(400, { errors: [], msg: "Content not found", code: 32 });
|
||||
const waiting = await district.check({}, p, "2026-09-25");
|
||||
assert.equal(waiting.kind, "closed");
|
||||
assert.match(waiting.note, /not listed yet/, "the reason must survive for the heartbeat");
|
||||
|
||||
stub(400, { errors: [], msg: "Mandatory search params are missing", code: 3 });
|
||||
await assert.rejects(() => district.check({}, p, "2026-09-25"), /Mandatory search params/,
|
||||
"a real config error must still raise the failure streak");
|
||||
|
||||
stub(500, {});
|
||||
await assert.rejects(() => district.check({}, p, "2026-09-25"), /HTTP 500/);
|
||||
|
||||
stub(204, {});
|
||||
assert.equal((await district.check({}, p, "2026-09-25")).kind, "closed");
|
||||
} finally {
|
||||
globalThis.fetch = realFetch;
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user