feat: make retry policy error-aware and expand unit coverage
- retry: retry only 5xx/429/transport errors; fail fast on 4xx - checks/diff/r2/cacheStore: add direct unit tests (D-08, D-10 area) - cacheStore: validate pullNumber in history object keys - r2: export normalizeEndpoint for testability
This commit is contained in:
1 parent
b47302e2ff
commit
3f793d746e
9 files changed
+363
-12
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { isR2Configured, normalizeEndpoint } from "../src/storage/r2.js";
|
||||
|
||||
test("normalizeEndpoint accepts credential-free https URLs and trims trailing slashes", () => {
|
||||
assert.equal(
|
||||
normalizeEndpoint("https://account.r2.cloudflarestorage.com"),
|
||||
"https://account.r2.cloudflarestorage.com"
|
||||
);
|
||||
assert.equal(
|
||||
normalizeEndpoint("https://account.r2.cloudflarestorage.com/"),
|
||||
"https://account.r2.cloudflarestorage.com"
|
||||
);
|
||||
});
|
||||
|
||||
test("normalizeEndpoint rejects non-https, credentialed, or decorated URLs", () => {
|
||||
assert.throws(() => normalizeEndpoint("http://insecure.example"), /credential-free HTTPS/);
|
||||
assert.throws(() => normalizeEndpoint("https://user:pass@host"), /credential-free HTTPS/);
|
||||
assert.throws(() => normalizeEndpoint("https://host/path?query=1"), /credential-free HTTPS/);
|
||||
assert.throws(() => normalizeEndpoint("not a url"), /valid HTTPS URL/);
|
||||
});
|
||||
|
||||
test("isR2Configured reflects ambient configuration without throwing", () => {
|
||||
// The test environment has no R2_* env vars set; the helper must not throw.
|
||||
assert.equal(typeof isR2Configured(), "boolean");
|
||||
});
|
||||
Reference in new issue
Block a user