mirror of
https://github.com/certd/certd.git
synced 2026-07-01 08:57:33 +08:00
chore: auto fix 存储标记,确保fix只运行一次
This commit is contained in:
@@ -2,9 +2,24 @@ import assert from "assert";
|
||||
import { AutoFix } from "./auto-fix.js";
|
||||
|
||||
describe("AutoFix", () => {
|
||||
it("runs fix tasks in order", async () => {
|
||||
it("runs unfinished fix tasks in order and marks them fixed", async () => {
|
||||
const calls: string[] = [];
|
||||
let savedSetting: any;
|
||||
const autoFix = new AutoFix();
|
||||
autoFix.sysSettingsService = {
|
||||
async getSetting() {
|
||||
return {
|
||||
fixed: {
|
||||
"oauth-subtype-bound-type": true,
|
||||
},
|
||||
};
|
||||
},
|
||||
async saveSetting(setting: any) {
|
||||
savedSetting = {
|
||||
fixed: { ...setting.fixed },
|
||||
};
|
||||
},
|
||||
} as any;
|
||||
autoFix.googleCommonEabAccountKeyFix = {
|
||||
async init() {
|
||||
calls.push("google");
|
||||
@@ -28,6 +43,26 @@ describe("AutoFix", () => {
|
||||
|
||||
await autoFix.init();
|
||||
|
||||
assert.deepEqual(calls, ["google", "oauth", "cert", "suite"]);
|
||||
assert.deepEqual(calls, ["google", "cert", "suite"]);
|
||||
assert.equal(savedSetting.fixed["google-common-eab-account-key"], true);
|
||||
assert.equal(savedSetting.fixed["oauth-subtype-bound-type"], true);
|
||||
assert.equal(savedSetting.fixed["cert-info-wildcard-domain-count"], true);
|
||||
assert.equal(savedSetting.fixed["suite-content-wildcard-domain-count"], true);
|
||||
});
|
||||
|
||||
it("initializes missing fixed map", async () => {
|
||||
const autoFix = new AutoFix();
|
||||
autoFix.sysSettingsService = {
|
||||
async getSetting() {
|
||||
return {};
|
||||
},
|
||||
async saveSetting() {},
|
||||
} as any;
|
||||
autoFix.googleCommonEabAccountKeyFix = { async init() {} } as any;
|
||||
autoFix.oauthSubtypeBoundTypeFix = { async init() {} } as any;
|
||||
autoFix.certInfoWildcardDomainCountFix = { async init() {} } as any;
|
||||
autoFix.suiteContentWildcardDomainCountFix = { async init() {} } as any;
|
||||
|
||||
await autoFix.init();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user